There is a click button in the work to update the button above the requirements of the case, with the custom button can be very simple implementation of this requirement
Start by writing a custom button
CustomButton.h
#import <UIKit/UIKit.h>typedef ns_enum (Nsuinteger, custombuttonstatus) { 0 , 1 }; @interface Custombutton:uibutton@property (nonatomic) custombuttonstatus buttonstatus; @end
Custombutton.m
#import "CustomButton.h"@implementationCustomButton- (void) Setbuttonstatus: (custombuttonstatus) buttonstatus{nsstring*title; if(Custombuttonstatusnormal = =buttonstatus) {Title=@" Oh, yes."; } Else if(Custombuttonstatusreverse = =buttonstatus) {Title=@" Oh, oh, oh."; } [self settitle:title forstate:uicontrolstatenormal]; _buttonstatus=Buttonstatus;}@end
Call
#import "ViewControllerTest.h"#import "CustomButton.h"@interfaceviewcontrollertest () {CustomButton*button;}@end@implementationviewcontrollertest- (void) viewdidload {[Super viewdidload]; Self.view.backgroundColor=[Uicolor Whitecolor]; Button=[CustomButton Buttonwithtype:uibuttontypecustom]; [Button Setbuttonstatus:custombuttonstatusnormal]; [Button Setframe:cgrectmake ( $, the, the, the)]; [Button addtarget:self action: @selector (Custombuttonclick:) forcontrolevents:uicontroleventtouchupinside]; [Button Setbackgroundcolor:[uicolor Redcolor]; [Self.view Addsubview:button];}-(void) custombuttonclick:sender{Button.buttonstatus= !Button.buttonstatus;}
IOS Custom UIButton