2013-12-18 33 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