UIButton *openvipbtn =[UIButton Buttonwithtype:uibuttontypecustom]; Openvipbtn.frame= CGRectMake (0,0, -, -); [Openvipbtn settitlecolor:[uicolor colorwithhexstring:@"e7923a"] Forstate:uicontrolstatenormal]; OpenVipBtn.titleLabel.font= [Uifont systemfontofsize: -]; [Openvipbtn setimage:[uiimage imagenamed:@"BOOKDETAILS_INTOVIP"] Forstate:uicontrolstatenormal]; Openvipbtn.backgroundcolor= [Uicolor colorwithhexstring:@"fff7ed"]; Openvipbtn.clipstobounds=YES; OpenVipBtn.layer.cornerRadius= the; [Self.view addsubview:openvipbtn];
Use:
[Self.view setopenvipbtntitle:@ "VIP can read this book for free, open VIP"];
-(void) Setopenvipbtntitle: (NSString *) title{ [self.openvipbtn settitle:title forstate: UIControlStateNormal]; = [title sizewithattributes:@{nsfontattributename:self.openvipbtn.titlelabel.font}].width; [Self.openvipbtn setimageedgeinsets:uiedgeinsetsmake (000)]; [Self.openvipbtn settitleedgeinsets:uiedgeinsetsmake (0,-00 )];}
ios--button inside the left text to the right of the picture settings