如何更改“添加联系人”按钮的颜色?

时间:2021-10-31 08:35:58

I want to change color of "Add Contact" button programmatically ?

我想要改变“添加联系人”按钮的颜色?

3 个解决方案

#1


3  

Use property tintColor of UIButton:

使用属性:

UIButton* addButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.tintColor = [UIColor whiteColor];

#2


2  

Make sure the button type is custom. Then doing the following will bring back those rounded corners:

确保按钮类型是自定义的。然后做以下的事情会使那些圆角回来:

[self.myButton.layer setCornerRadius:8.0f];
[self.myButton.layer setMasksToBounds:YES];
[self.myButton.layer setBorderWidth:1.0f];
[self.myButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
self.myButton.backgroundColor = [UIColor redColor];

Though, personally, I'm a big fan of gradient buttons over solid colors... also, background color doesn't have different states, whereas background images do:

不过,就我个人而言,我非常喜欢用纯色的渐变按钮……此外,背景颜色没有不同的状态,而背景图片有:

[self.myButton setBackgroundImage:[UIImage imageNamed:@"gradient.png"] forState:UIControlStateNormal];

Using an image, your button will darken with selection (or you could provide a different background image per state to do something different). This won't happen with background color, the background will always stay the same, only your button label changing per state.

使用一个图像,你的按钮会变暗(或者你可以为每个州提供不同的背景图像来做一些不同的事情)。这不会发生与背景颜色,背景将始终保持不变,只有你的按钮标签改变每个状态。

#3


-2  

Using CSS I assume. But honestly, this isn't a very good question. What "Add Contact" button? Is this a webpage embedded button? Is it in a GUI application? What have you tried, if anything?

使用CSS我假设。但老实说,这不是一个很好的问题。“添加联系人”按钮呢?这是网页嵌入按钮吗?它在GUI应用程序中吗?你试过了吗?

This question doesn't help anybody, not us and not you. And if someone else has the same problem, they're more likely to Google for "Change Add Contact button color in [[Program Name / Website]]". This will not necessarily come up because there's little to no detail.

这个问题对任何人都没有帮助,不是我们,也不是你。如果其他人也有同样的问题,他们更有可能在谷歌中“修改[[[[程序名称/网站]]]中添加联系人按钮颜色”。这并不一定会出现,因为几乎没有细节。

I'm told you are likely talking about iPhone. But take a look at this link it may help: http://modmyi.com/forums/skinning-themes-discussion/768633-theming-ios-5-x.html

我听说你可能在谈论iPhone。但是看看这个链接可能会有帮助:http://modmyi.com/forums/skinning-themes-discussion/768633-theming-ios-5-x.html

#1


3  

Use property tintColor of UIButton:

使用属性:

UIButton* addButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.tintColor = [UIColor whiteColor];

#2


2  

Make sure the button type is custom. Then doing the following will bring back those rounded corners:

确保按钮类型是自定义的。然后做以下的事情会使那些圆角回来:

[self.myButton.layer setCornerRadius:8.0f];
[self.myButton.layer setMasksToBounds:YES];
[self.myButton.layer setBorderWidth:1.0f];
[self.myButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
self.myButton.backgroundColor = [UIColor redColor];

Though, personally, I'm a big fan of gradient buttons over solid colors... also, background color doesn't have different states, whereas background images do:

不过,就我个人而言,我非常喜欢用纯色的渐变按钮……此外,背景颜色没有不同的状态,而背景图片有:

[self.myButton setBackgroundImage:[UIImage imageNamed:@"gradient.png"] forState:UIControlStateNormal];

Using an image, your button will darken with selection (or you could provide a different background image per state to do something different). This won't happen with background color, the background will always stay the same, only your button label changing per state.

使用一个图像,你的按钮会变暗(或者你可以为每个州提供不同的背景图像来做一些不同的事情)。这不会发生与背景颜色,背景将始终保持不变,只有你的按钮标签改变每个状态。

#3


-2  

Using CSS I assume. But honestly, this isn't a very good question. What "Add Contact" button? Is this a webpage embedded button? Is it in a GUI application? What have you tried, if anything?

使用CSS我假设。但老实说,这不是一个很好的问题。“添加联系人”按钮呢?这是网页嵌入按钮吗?它在GUI应用程序中吗?你试过了吗?

This question doesn't help anybody, not us and not you. And if someone else has the same problem, they're more likely to Google for "Change Add Contact button color in [[Program Name / Website]]". This will not necessarily come up because there's little to no detail.

这个问题对任何人都没有帮助,不是我们,也不是你。如果其他人也有同样的问题,他们更有可能在谷歌中“修改[[[[程序名称/网站]]]中添加联系人按钮颜色”。这并不一定会出现,因为几乎没有细节。

I'm told you are likely talking about iPhone. But take a look at this link it may help: http://modmyi.com/forums/skinning-themes-discussion/768633-theming-ios-5-x.html

我听说你可能在谈论iPhone。但是看看这个链接可能会有帮助:http://modmyi.com/forums/skinning-themes-discussion/768633-theming-ios-5-x.html