jjzjj

forState

全部标签

ios - IBInspectable setTitle :forState on UIButton not working

我正在尝试使用InterfaceBuilder中的实时呈现为UIButtons实现一个可本地化的类。这是我到目前为止的代码:@IBDesignableclassTIFLocalizableButton:UIButton{@IBInspectablevarlocalizeString:String=""{didSet{#ifTARGET_INTERFACE_BUILDERvarbundle=NSBundle(forClass:self.dynamicType)self.setTitle(bundle.localizedStringForKey(self.localizeString,va

ios - UIButton -setTitle : forState: doesn't seem to work

我正在尝试动态更新UIButton的IBOutletCollection的标题。我希望标题设置为选中时字母“S”和禁用和选中时的文本“D|S”。它不工作,所以我打印了titleForState:,看起来标题没有正确设置。我是否正确使用了setTitle:forState:?@property(strong,nonatomic)IBOutletCollection(UIButton)NSArray*buttons;...-(void)updateUI//CallingthisfromIBAction{for(UIButton*buttoninself.buttons){[buttonse

ios - UIButton -setTitle : forState: doesn't seem to work

我正在尝试动态更新UIButton的IBOutletCollection的标题。我希望标题设置为选中时字母“S”和禁用和选中时的文本“D|S”。它不工作,所以我打印了titleForState:,看起来标题没有正确设置。我是否正确使用了setTitle:forState:?@property(strong,nonatomic)IBOutletCollection(UIButton)NSArray*buttons;...-(void)updateUI//CallingthisfromIBAction{for(UIButton*buttoninself.buttons){[buttonse

ios - 阻止 UIButton 的 setTitle :forState: animation

这个问题在这里已经有了答案:HowtostopunwantedUIButtonanimationontitlechange?(24个答案)关闭6年前。我正在使用NSTimer每秒更新一个UIButton的标题。它可以工作,但标题中的文本会自动闪烁(动画显示为alpha0并返回)。我尝试使用button.layer.removeAllAnimations()但没有成功,也没有异常(exception),因此QuartzCore似乎已正确链接。当前无效的偏执代码:UIView.setAnimationsEnabled(false)UIView.performWithoutAnimation

ios - 阻止 UIButton 的 setTitle :forState: animation

这个问题在这里已经有了答案:HowtostopunwantedUIButtonanimationontitlechange?(24个答案)关闭6年前。我正在使用NSTimer每秒更新一个UIButton的标题。它可以工作,但标题中的文本会自动闪烁(动画显示为alpha0并返回)。我尝试使用button.layer.removeAllAnimations()但没有成功,也没有异常(exception),因此QuartzCore似乎已正确链接。当前无效的偏执代码:UIView.setAnimationsEnabled(false)UIView.performWithoutAnimation

ios - 突出显示/选定状态问题的 UIButton 背景颜色

我有一个UIButton并且我创建了一个扩展来为不同的状态添加背景颜色。我正在使用以下代码:extensionUIButton{funcsetBackgroundColor(color:UIColor,forState:UIControlState){UIGraphicsBeginImageContext(CGSize(width:1,height:1))CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),color.CGColor)CGContextFillRect(UIGraphicsGetCurrentCont

ios - 突出显示/选定状态问题的 UIButton 背景颜色

我有一个UIButton并且我创建了一个扩展来为不同的状态添加背景颜色。我正在使用以下代码:extensionUIButton{funcsetBackgroundColor(color:UIColor,forState:UIControlState){UIGraphicsBeginImageContext(CGSize(width:1,height:1))CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),color.CGColor)CGContextFillRect(UIGraphicsGetCurrentCont

ios - 为什么 UIButton 框架被 setTitle : forState: method 重置

问题如下:在某个时刻,按钮的位置发生了变化。在此之后,按钮的标题也必须更改。位置由动画(UIView动画block)改变,当设置标题时,帧返回到原始值(在动画之前)。那么...我该如何解决?为什么会这样?更新代码CGRectbuttonFrame=self.button.frame;buttonFrame.origin=CGPointMake(16,80);[UIViewanimateWithDuration:.4animations:^{[self.buttonsetFrame:buttonFrame];}completion:^(BOOLfinished){[self.button

ios - UIButton setImage : forState not working with 64 bit architecture

我有一年前创建的现有项目。在AppStore的64位需求公告之后,我不得不将arm64架构包含到我的项目中但是在将arm64添加到appTarget->BuildSettings->ValidArchitectures之后,所有UIButton的所有setImage:forState方法对象停止工作,而setBackGroundImage:forState正常工作。UIButton*button=[[UIButtonalloc]initWithFrame:CGRectMake(10,10,20,20)];[buttonsetImage:imageforState:UIControlSt

ios - setImage forState 方法为按钮上的所有状态设置图像

我有一个我无法解决的小问题。我有大约16个按钮,它们作为socket集合连接到我的Controller。它们还有一个操作方法,可以使按钮的状态从默认状态更改为选中状态。我试图将所有按钮的图像更改为仅默认状态。所以我在数组中运行一个循环,并使用setImage:forState:方法将它们的图像设置为默认状态。然而,该方法会更改所有状态(默认和选定状态)的图像。这是我的outlet集合的setter方法-(void)setCardsButton:(NSArray*)cardsButton{_cardsButton=cardsButton;for(UIButton*buttonincard