草庐IT

UIBUTTON

全部标签

ios - 如何将 UIButton 用作切换按钮?

我正在尝试为表格中的每个单元格创建一个切换按钮。按下时,它会改变图像,再次按下时它会再次改变图像——切换。在UIButton类中,我没有看到selected状态。我正在寻找一种使用UIButton创建切换按钮的方法,以便我可以在每次单击时更改状态。这就是我现在使用rmq在rubymotion中做的事情@fav_button.on(:touch)do|sender|puts"pressedfavbuttonforid:"+data[:id]+"andname:"+data[:name]#howdoIchangethestatehere?end 最佳答案

ios - 设置 UIButton 背景的 alpha 但不是标题

当我设置按钮的alpha时,它也会影响标题的不透明度。有没有办法只定位背景并将标题alpha保留为1.0? 最佳答案 这对我有用:self.myButton.backgroundColor=[UIColorclearColor];或者如果你不想让它完全清晰,但仍然可以使用:self.myButton.backgroundColor=[UIColorcolorWithRed:200.0/255.0green:200.0/255.0blue:200.0/255.0alpha:0.5];第二个示例将为您提供alpha0.5的灰色。SWIF

ios - 设置 UIButton 背景的 alpha 但不是标题

当我设置按钮的alpha时,它也会影响标题的不透明度。有没有办法只定位背景并将标题alpha保留为1.0? 最佳答案 这对我有用:self.myButton.backgroundColor=[UIColorclearColor];或者如果你不想让它完全清晰,但仍然可以使用:self.myButton.backgroundColor=[UIColorcolorWithRed:200.0/255.0green:200.0/255.0blue:200.0/255.0alpha:0.5];第二个示例将为您提供alpha0.5的灰色。SWIF

iphone - 如何在 iphone 中以编程方式实现带有背景图像的按钮

我正在iPhone中以编程方式使用按钮开发图像。现在我想为下一个和上一个按钮添加按钮背景图像。我想以编程方式为这些按钮添加图像。如何在iphone中添加按钮图片。 最佳答案 //像这样添加按钮UIImage*redButtonImage=[UIImageimageNamed:@"ExitButton.png"];UIButton*redButton=[UIButtonbuttonWithType:UIButtonTypeCustom];redButton.frame=CGRectMake(280.0,10.0,29.0,29.0);

iphone - 如何在 iphone 中以编程方式实现带有背景图像的按钮

我正在iPhone中以编程方式使用按钮开发图像。现在我想为下一个和上一个按钮添加按钮背景图像。我想以编程方式为这些按钮添加图像。如何在iphone中添加按钮图片。 最佳答案 //像这样添加按钮UIImage*redButtonImage=[UIImageimageNamed:@"ExitButton.png"];UIButton*redButton=[UIButtonbuttonWithType:UIButtonTypeCustom];redButton.frame=CGRectMake(280.0,10.0,29.0,29.0);

ios - UIButton 不自动调整字体大小

我正在以编程方式将UIButton添加到我的View中,我希望按钮中的字体大小会自动调整它的大小(例如,如果文本很长,请调整为较小的字体以适合按钮)。此代码无效(字体始终相同):myButton=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[myButtonsetTitle:[NSStringstringWithFormat:@"hello"]forState:UIControlStateNormal];[myButtonsetFrame:CGRectMake(0,0,180,80)];[myButton.titleLabelset

ios - UIButton 不自动调整字体大小

我正在以编程方式将UIButton添加到我的View中,我希望按钮中的字体大小会自动调整它的大小(例如,如果文本很长,请调整为较小的字体以适合按钮)。此代码无效(字体始终相同):myButton=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[myButtonsetTitle:[NSStringstringWithFormat:@"hello"]forState:UIControlStateNormal];[myButtonsetFrame:CGRectMake(0,0,180,80)];[myButton.titleLabelset

ios - 如何设置按钮的背景颜色 - xcode

如何在Xcode中设置UIButton的背景颜色?我在布局属性中看到属性Background和Image,但我无法在这两个中设置任何内容。(我只能设置两种颜色的图像) 最佳答案 只需在AttributeInspector中稍微滚动一下,您就可以在view部分找到Background属性,它允许您设置UIButton的backgroundColor。如果你想以编程方式设置按钮的backgroundColor。objective-c:self.yourButton.backgroundColor=[UIColorredColor];Sw

ios - 如何设置按钮的背景颜色 - xcode

如何在Xcode中设置UIButton的背景颜色?我在布局属性中看到属性Background和Image,但我无法在这两个中设置任何内容。(我只能设置两种颜色的图像) 最佳答案 只需在AttributeInspector中稍微滚动一下,您就可以在view部分找到Background属性,它允许您设置UIButton的backgroundColor。如果你想以编程方式设置按钮的backgroundColor。objective-c:self.yourButton.backgroundColor=[UIColorredColor];Sw

ios - 如何永久取消选择分段控制按钮中的段,直到再次单击

我有一个包含4个段的UISegmentedControl。当它被选中时,它应该保持选中状态。再次单击同一段时,它应该取消选择自己。如何实现? 最佳答案 由于UISegmentedControl仅在未选择的段被选中时才发送Action,因此您必须子类化UISegmentedControl以对其触摸处理进行微小的更改。我使用这个类:@implementationMBSegmentedControl//thissendsavaluechangedeventevenifwereselectthecurrentlyselectedsegmen