我像这样使用setBackgroundImage:forState:来为各种状态着色背景图像的颜色:

[myButton setBackgroundImage:genericImage forStates:UIControlStateNormal];
[myButton setBackgroundImage:buttonBackgroundPressed
                   forStates:UIControlStateHighlighted];


是否有一种方法可以对此方法直接设置动画/淡入/淡出持续时间过渡?

最佳答案

这对我有用:

-(void) init{
  [myButton addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)touchUp:(id)sender
{
  UIButton* btn = sender;
  [UIView animateWithDuration:1.0 animations:^{
    btn.alpha = 0.5;
  }];
}

关于ios - setBackgroundImage:forState:动画/过渡?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21620950/

10-12 02:12