怎么获取UIButton标题?
UIButton在不同状态(被点击\正常状态\不可用\ ...)标题是可以不同的
按钮的状态
typedefNS_OPTIONS(NSUInteger,UIControlState){UIControlStateNormal=0,UIControlStateHighlighted=1<<0,//usedwhenUIControlisHighlightedissetUIControlStateDisabled=1<<1,UIControlStateSelected=1<<2,//flagusablebyapp(seebelow)UIControlStateFocusedNS_ENUM_AVAILABLE_IOS(9_0)=1<<3,//ApplicableonlywhenthescreensupportsfocusUIControlStateApplication=0x00FF0000,//additionalflagsavailableforapplicationuseUIControlStateReserved=0xFF000000//flagsreservedforinternalframeworkuse};
以下代码获取正常状态下的标题,并赋值给别的变量
UIControlStateNormal为正常状态
-(IBAction)buttonPressed:(UIButton*)sender{NSString*title=[sendertitleForState:UIControlStateNormal];NSString*plainText=[NSStringstringWithFormat:@"%@buttonpressed.",title];_statusLable.text=plainText;}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。