怎么获取UIButton标题?
UIButton在不同状态(被点击\正常状态\不可用\ ...)标题是可以不同的
创新互联公司是一家专业提供南海企业网站建设,专注与成都网站制作、成都做网站、H5建站、小程序制作等业务。10年已为南海众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
按钮的状态
typedef NS_OPTIONS(NSUInteger, UIControlState) { UIControlStateNormal = 0, UIControlStateHighlighted = 1 << 0, // used when UIControl isHighlighted is set UIControlStateDisabled = 1 << 1, UIControlStateSelected = 1 << 2, // flag usable by app (see below) UIControlStateFocused NS_ENUM_AVAILABLE_IOS(9_0) = 1 << 3, // Applicable only when the screen supports focus UIControlStateApplication = 0x00FF0000, // additional flags available for application use UIControlStateReserved = 0xFF000000 // flags reserved for internal framework use };
以下代码获取正常状态下的标题,并赋值给别的变量
UIControlStateNormal为正常状态
- (IBAction)buttonPressed:(UIButton *)sender { NSString *title = [sender titleForState:UIControlStateNormal]; NSString *plainText = [NSString stringWithFormat:@"%@ button pressed.", title]; _statusLable.text = plainText; }
新闻标题:怎么获取UIButton标题?
URL标题:http://azwzsj.com/article/pdssdg.html