#import "buttonCustom.h"#defineKimagew 30#defineKtitleh 21#defineKpadding 10@interfaceButtoncustom ()@end@implementationButtoncustom-(Instancetype) initWithFrame: (cgrect) frame{if(self =[Super Initwithframe:frame]) {self.titleLabel.textAlignment=Nstextalignmentcenter; } returnSelf ;}//Set Title- (void) Settitle: (NSString *title forstate: (uicontrolstate) state{[Super Settitle:title forstate:state]; }//Set Image- (void) SetImage: (UIImage *) Image forstate: (uicontrolstate) state{[Super Setimage:image forstate:state]; }//Custom Title Rect-(CGRect) Titlerectforcontentrect: (cgrect) contentrect{returnCGRectMake (0, kpadding *2, Self.bounds.size.width, + );}//Custom Image Rect-(CGRect) Imagerectforcontentrect: (cgrect) contentrect{returnCGRectMake (0, Kpadding, Self.bounds.size.width, Kimagew);}@end
Custom button picture in the above text below