gpt4 book ai didi

ios - 设置背景图像 :forState: animation/transition?

转载 作者:行者123 更新时间:2023-11-28 22:16:07 25 4
gpt4 key购买 nike

我正在使用 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 - 设置背景图像 :forState: animation/transition?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21620950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com