十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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; }