2013-12-18 32 views
3
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
    btn.titleLabel.shadowColor = [UIColor blackColor]; 
    btn.titleLabel.shadowOffset = CGSizeMake(1, 1); 

当我在ios7上运行这个按钮时,该按钮根本没有阴影。给你的建议。iOS:UIButton的标题阴影颜色不起作用

+0

u可以使用层为 –

+0

要在按钮添加阴影或按钮标题? – mengxiangjian

+0

[Uibutton titlelabel shadowoffset属性在ios 7中的行为不正确]的可能的重复(http://stackoverflow.com/questions/19142652/uibutton-titlelabel-shadowoffset-property-is-not-behaving-properly-in-ios- 7) – rmaddy

回答

3

尝试用下面的代码按钮的标题

[button setTitleShadowColor:[UIColor blackColor] forState:UIControlStateNormal]; 

的给予阴影,如果你想给按钮阴影然后阅读下面的链接。

Add border and shadow to the buttons

4

第一添加“QuartzCore”库UR项目和#import <QuartzCore/QuartzCore.h>这乌尔班,做财产以后这样

btn.titleLabel.layer.shadowColor = [UIColor blackColor].CGColor;//set preferred color 
btn.titleLabel.layer.shadowOpacity = 0.7;//set opacity