iOS development UIButton to the left picture, the picture followed by the text effect

Source: Internet
Author: User

In the use of UIButton, you need to implement UIButton left picture, the picture behind the word effect is more troublesome, simple implementation of the specific code as follows:

-(void) Viewdidload {
[Super Viewdidload];
Self.view.backgroundColor = RGB (235, 235, 240);
UIButton *onebutton = [[UIButton alloc] Initwithframe:cgrectmake (0, Kheaderheight + 8, Kscreenwidth, 40)];
[Onebutton setimage:[uiimage imagenamed:@ "Icon_party_knowledge_rights_obligations"] ForState:UIControlStateNormal ];
[Onebutton settitle:@ "The first" forstate:uicontrolstatenormal];
OneButton.titleLabel.font = Font (12);
[Onebutton Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal];
[Onebutton Setimageedgeinsets:uiedgeinsetsmake (2, 8, 0, kScreenWidth-50)];
[Onebutton settitleedgeinsets:uiedgeinsetsmake (0, 0, 0, kScreenWidth-100)];
Onebutton.backgroundcolor = [Uicolor Whitecolor];
[Onebutton addtarget:self Action: @selector (onebuttonaction:) forcontrolevents:uicontroleventtouchupinside];
[Self.view Addsubview:onebutton];

UIButton *twobutton = [[UIButton alloc] Initwithframe:cgrectmake (0, Onebutton.maxy + 8, Kscreenwidth, 40)];
[Twobutton setimage:[uiimage imagenamed:@ "Icon_party_knowledge_dues_collection_standard"] forState: UIControlStateNormal];
[Twobutton settitle:@ "The second" forstate:uicontrolstatenormal];
TwoButton.titleLabel.font = Font (12);
[Twobutton Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal];
[Twobutton Setimageedgeinsets:uiedgeinsetsmake (2, 8, 0, kScreenWidth-50)];
[Twobutton settitleedgeinsets:uiedgeinsetsmake (0, 0, 0, kScreenWidth-100)];
Twobutton.backgroundcolor = [Uicolor Whitecolor];
[Twobutton addtarget:self Action: @selector (twobuttonaction:) forcontrolevents:uicontroleventtouchupinside];
[Self.view Addsubview:twobutton];

Right Arrow
for (int i = 0; i < 2; i++) {
Uiimageview *rightimgview = [[Uiimageview alloc] Initwithframe:cgrectmake (kScreenWidth-20, kheaderheight + + i * 48, 7, 12)];
Rightimgview.image = [UIImage imagenamed:@ "Icon_right"];
[Self.view Addsubview:rightimgview];
}
}

The effect looks like this

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.