草庐IT

UiButton

全部标签

ios - 从 UIColor 创建 UIImage 以用作 UIButton 的背景图像

这个问题在这里已经有了答案:Howtocreateacolored1x1UIImageontheiPhonedynamically?(6个回答)关闭7年前。我正在创建这样的彩色图像:CGRectrect=CGRectMake(0,0,1,1);UIGraphicsBeginImageContext(rect.size);CGContextRefcontext=UIGraphicsGetCurrentContext();CGContextSetFillColorWithColor(context,[[UIColorredColor]CGColor]);//[[UIColorcolorWi

ios - 从 UIColor 创建 UIImage 以用作 UIButton 的背景图像

这个问题在这里已经有了答案:Howtocreateacolored1x1UIImageontheiPhonedynamically?(6个回答)关闭7年前。我正在创建这样的彩色图像:CGRectrect=CGRectMake(0,0,1,1);UIGraphicsBeginImageContext(rect.size);CGContextRefcontext=UIGraphicsGetCurrentContext();CGContextSetFillColorWithColor(context,[[UIColorredColor]CGColor]);//[[UIColorcolorWi

ios - UIButton:如何使用 imageEdgeInsets 和 titleEdgeInsets 使图像和文本居中?

如果我只在按钮中放置一个图像并将imageEdgeInsets设置为更靠近顶部,则图像将保持居中并且一切都按预期工作:[buttonsetImage:imageforState:UIControlStateNormal];[buttonsetImageEdgeInsets:UIEdgeInsetsMake(-15.0,0.0,0.0,0.0)];如果我只在按钮中放置一个文本并将titleEdgeInsets设置为更靠近底部,则文本将保持居中并且一切都按预期工作:[buttonsetTitle:titleforState:UIControlStateNormal];[buttonsetT

ios - UIButton:如何使用 imageEdgeInsets 和 titleEdgeInsets 使图像和文本居中?

如果我只在按钮中放置一个图像并将imageEdgeInsets设置为更靠近顶部,则图像将保持居中并且一切都按预期工作:[buttonsetImage:imageforState:UIControlStateNormal];[buttonsetImageEdgeInsets:UIEdgeInsetsMake(-15.0,0.0,0.0,0.0)];如果我只在按钮中放置一个文本并将titleEdgeInsets设置为更靠近底部,则文本将保持居中并且一切都按预期工作:[buttonsetTitle:titleforState:UIControlStateNormal];[buttonsetT

ios - 如何在 UIButton 中创建边框?

我在名为“addButton”的应用程序中使用自定义按钮,我想用白色为其添加边框,如何在自定义按钮周围设置白色边框? 最佳答案 您可以通过访问按钮的图层属性来设置CALayer上的边框属性。首先,添加quartz#import设置属性:myButton.layer.borderWidth=2.0f;myButton.layer.borderColor=[UIColorgreenColor].CGColor;见:https://developer.apple.com/documentation/quartzcore/calayer#/

ios - 如何在 UIButton 中创建边框?

我在名为“addButton”的应用程序中使用自定义按钮,我想用白色为其添加边框,如何在自定义按钮周围设置白色边框? 最佳答案 您可以通过访问按钮的图层属性来设置CALayer上的边框属性。首先,添加quartz#import设置属性:myButton.layer.borderWidth=2.0f;myButton.layer.borderColor=[UIColorgreenColor].CGColor;见:https://developer.apple.com/documentation/quartzcore/calayer#/

ios - 如何更改 UIButton 标题颜色?

我以编程方式创建了一个按钮............button=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[buttonaddTarget:selfaction:@selector(aMethod:)forControlEvents:UIControlEventTouchDown];[buttonsetTitle:@"ShowView"forState:UIControlStateNormal];button.frame=CGRectMake(80.0,210.0,160.0,40.0);[viewaddSubview:butto

ios - 如何更改 UIButton 标题颜色?

我以编程方式创建了一个按钮............button=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[buttonaddTarget:selfaction:@selector(aMethod:)forControlEvents:UIControlEventTouchDown];[buttonsetTitle:@"ShowView"forState:UIControlStateNormal];button.frame=CGRectMake(80.0,210.0,160.0,40.0);[viewaddSubview:butto

ios - 在代码中为 UIButton 设置图像

如何在代码中为UIButton设置图像?我有这个:UIButton*btnTwo=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];btnTwo.frame=CGRectMake(40,140,240,30);[btnTwosetTitle:@"vc2:v1"forState:UIControlStateNormal];[btnTwoaddTarget:selfaction:@selector(goToOne)forControlEvents:UIControlEventTouchUpInside];[self.viewaddSubvie

ios - 在代码中为 UIButton 设置图像

如何在代码中为UIButton设置图像?我有这个:UIButton*btnTwo=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];btnTwo.frame=CGRectMake(40,140,240,30);[btnTwosetTitle:@"vc2:v1"forState:UIControlStateNormal];[btnTwoaddTarget:selfaction:@selector(goToOne)forControlEvents:UIControlEventTouchUpInside];[self.viewaddSubvie