草庐IT

uibuttons

全部标签

iphone - 子类化 UIButton 添加一个属性

我想将UIButton子类化以添加一些我需要的属性(不是方法...只有属性)。这里是我的子类的代码://.h-----------------------@interfaceMyButton:UIButton{MyPropertyType*property;}@property(nonatomic,retain)MyPropertyType*property;@end//.m--------------------------@implementationMyButton@synthesizeproperty;@end下面是我如何使用这个类:MyButton*btn=((MytButt

ios - 为什么我的 UIButton.tintColor 不工作?

我的构建目标是为IOS5设置的,据我所知,UIButton.tintColor被引入...我在ViewController的viewDidLoad中有这个[timelineButtonsetTintColor:[UIColorblackColor]];[timelineButtonsetTitle:@"test"forState:UIControlStateNormal];文本正确更改但按钮不是黑色?谢谢! 最佳答案 根据documentation:Thispropertyisnotvalidforallbuttontypes.您需

ios - 为什么我的 UIButton.tintColor 不工作?

我的构建目标是为IOS5设置的,据我所知,UIButton.tintColor被引入...我在ViewController的viewDidLoad中有这个[timelineButtonsetTintColor:[UIColorblackColor]];[timelineButtonsetTitle:@"test"forState:UIControlStateNormal];文本正确更改但按钮不是黑色?谢谢! 最佳答案 根据documentation:Thispropertyisnotvalidforallbuttontypes.您需

ios - 如何在 UIButton 中不拉伸(stretch)图像

我正在尝试以编程方式创建自定义UITableViewCell,此单元格的subview之一将是一个带有图像的按钮(放大镜的简单图像)。但是,我希望按钮的图像居中并按比例缩小以适合按钮而不是拉伸(stretch)以填充整个按钮。下面是我的代码,其中self指的是我将按钮放入其中的自定义UITableViewCell。self.myButton=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[self.myButtonsetBackgroundImage:[UIImageimageNamed:@image_name_here"]forSt

ios - 如何在 UIButton 中不拉伸(stretch)图像

我正在尝试以编程方式创建自定义UITableViewCell,此单元格的subview之一将是一个带有图像的按钮(放大镜的简单图像)。但是,我希望按钮的图像居中并按比例缩小以适合按钮而不是拉伸(stretch)以填充整个按钮。下面是我的代码,其中self指的是我将按钮放入其中的自定义UITableViewCell。self.myButton=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[self.myButtonsetBackgroundImage:[UIImageimageNamed:@image_name_here"]forSt

ios - 更改 Storyboard 中的 UIButton BorderColor

我在用户定义的运行时属性中为UIbutton设置了CornerRadius和BorderWidth。在不添加layer.borderColor的情况下,它可以正常工作并以黑色显示边框。但是当添加layer.borderColor时不起作用(不显示边框)。 最佳答案 对于Swift:swift3:extensionUIView{@IBInspectablevarcornerRadius:CGFloat{get{returnlayer.cornerRadius}set{layer.cornerRadius=newValuelayer.m

ios - 更改 Storyboard 中的 UIButton BorderColor

我在用户定义的运行时属性中为UIbutton设置了CornerRadius和BorderWidth。在不添加layer.borderColor的情况下,它可以正常工作并以黑色显示边框。但是当添加layer.borderColor时不起作用(不显示边框)。 最佳答案 对于Swift:swift3:extensionUIView{@IBInspectablevarcornerRadius:CGFloat{get{returnlayer.cornerRadius}set{layer.cornerRadius=newValuelayer.m

ios - 如何缩放 UIButton 的 imageView?

我使用[UIButtonsetImage:forState:]使用图像创建了一个名为“button”的UIButton实例。button.frame大于图像的大小。现在我想缩小这个按钮的图像。我尝试更改button.imageView.frame、button.imageView.bounds和button.imageView.contentMode,但似乎都无效。谁能帮我缩放UIButton的imageView?我像这样创建了UIButton:UIButton*button=[[UIButtonalloc]init];[buttonsetImage:imageforState:UIC

ios - 如何缩放 UIButton 的 imageView?

我使用[UIButtonsetImage:forState:]使用图像创建了一个名为“button”的UIButton实例。button.frame大于图像的大小。现在我想缩小这个按钮的图像。我尝试更改button.imageView.frame、button.imageView.bounds和button.imageView.contentMode,但似乎都无效。谁能帮我缩放UIButton的imageView?我像这样创建了UIButton:UIButton*button=[[UIButtonalloc]init];[buttonsetImage:imageforState:UIC

swift - 如何在 UIButton 的右边缘对齐 UIButton 图像

如何将图像与UIButton的右边缘对齐,以便它在所有设备上都保持在右边缘。下图显示了带有图像(圆形-三角形)的UIButton。该图像是iPhone6的屏幕截图,符合我的要求。但对于iPhone6+,图像向左移动了一点,对于iPhone5,它向右移动,图像显示在用户界面按钮。我知道这是为什么,因为我将UIEdgeInsets的左值设置为300,非常适合iPhone6。所以我的问题是如何为所有iPhone实现这种外观。谢谢。我的UIButton代码:classDropDownButton:UIButton{requiredinit(coderaDecoder:NSCoder){supe