相关疑难解决方法(0)

iPad:动画UILabels变色

我有一个标签,在我的应用程序中弹出显示点.我使用以下代码使标签的规模变大,然后变小.我还想将颜色从紫色变为绿色.有人能指出我实现这一目标的资源吗?

mLabel.textColor = [UIColor purpleColor];

 [UIView beginAnimations:nil context:NULL];
 [UIView setAnimationDuration:1.0];
 [UIView setAnimationDelegate:self];
 mLabel.transform = CGAffineTransformMakeScale(1.5,1.5);
 [UIView setAnimationRepeatCount:1];
 mLabel.transform = CGAffineTransformMakeScale(0.5,0.5);
 mLabel.textColor = [UIColor greenColor];
 [UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

iphone animation ios

19
推荐指数
3
解决办法
2万
查看次数

是否有可能为UILabel的文本颜色变化制作动画?

 UIView.animateWithDuration(5, animations: {
        myLabel.textColor = UIColor.redColor()
    })
Run Code Online (Sandbox Code Playgroud)

标签文字颜色立即改变

objective-c ios swift

6
推荐指数
2
解决办法
5317
查看次数

UILabel的实际动画是什么?

我试图为backgroundColorUILabel类的属性设置动画并且到目前为止都没有成功.这是我的代码片段

-(void) blink {
  UIColor* originalColor = lblDescription.backgroundColor;
  lblDescription.backgroundColor = [UIColor yellowColor];

  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:1.0];
  lblDescription.backgroundColor = originalColor;
  [UIView commitAnimations];
}
//this code works if lblDescription is UIView and does not if UILabel
Run Code Online (Sandbox Code Playgroud)

我发现了一些要求,一些的UILabel属性不是动画,但我无法通过阅读苹果文档证实这种说法.我想知道是否有人可以解释这个问题.

iphone cocoa-touch core-animation uikit

5
推荐指数
1
解决办法
1189
查看次数

在Swift中为UILabel文本颜色设置动画

如何使用swift为UILabel的颜色变化设置动画?我见过人们提到使用CALayer,但我无法弄清楚Swift的语法.

这是Objective-C的一个例子

CALayer *layer = myView.layer;
CATextLayer *textLayer = [CATextLayer layer];
[textLayer setString:@"My string"];
[textLayer setForegroundColor:initialColor;
[textLayer setFrame:self.bounds];
[[self.view layer] addSublayer:textLayer];

[UIView animateWithDuration:0.5 animations:^{
     textLayer.foregroundColor = finalColor;
   }];
Run Code Online (Sandbox Code Playgroud)

iphone calayer uilabel ios swift

4
推荐指数
1
解决办法
1万
查看次数

UILabel的backgroundColor是不可动画的?

我有一个gridView,我用来显示几个GridViewCell : UIView.在GidViewCell增加了一个的UILabel本身并附加一个UITapGestureRecognizer自己.

UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[self addGestureRecognizer:gestureRecognizer];
[gestureRecognizer release];
Run Code Online (Sandbox Code Playgroud)

tapped:我想播放一些动画,包括更改标签的背景颜色

- (void) tapped:(id)sender {
    [UIView animateWithDuration:1.0
                          delay:0
                        options:(UIViewAnimationOptionAllowUserInteraction)
                     animations:^{ 
                         [(UILabel *)[[self subviews] objectAtIndex:0] setBackgroundColor:[UIColor blueColor]];
                     }  
                     completion:^(BOOL finished){
                         [(UILabel *)[[self subviews] objectAtIndex:0] setBackgroundColor:[UIColor whiteColor]];
                     }
     ];     
[self.delegate didSelectGridViewCell:self];
}
Run Code Online (Sandbox Code Playgroud)

但是标签只是闪烁蓝色一眨眼 - 如果有的话.如果我使用相同的代码,但调整标签的alpha而不是背景颜色,一切都按预期工作.

Apple的文档将backgroundColor列为动画.是吗?难道我做错了什么?

cocoa-touch objective-c uianimation ios

3
推荐指数
1
解决办法
3310
查看次数