iOS UIButton how to text in the next picture on

Source: Internet
Author: User

Create subclasses inherit from UIButton, change the position of the text and picture in the Layoutsubviews method, in the same way, a little change, you can write the text in the film. This article only gives the text on the piece in the code

1-(void) Layoutsubviews {2 [Super Layoutsubviews];3     4     //Image Center5Cgpoint Center;6Center.x = self.frame.size.width/2;7CENTER.Y = self.imageview.frame.size.height/2;8Self.imageView.center =Center;9     Ten     //text OneCGRect Newframe =[self titlelabel].frame; ANewframe.origin.x =0; -NEWFRAME.ORIGIN.Y = Self.imageView.frame.size.height +5; -NewFrame.size.width =Self.frame.size.width; the      -Self.titleLabel.frame =Newframe; -Self.titleLabel.textAlignment =Nstextalignmentcenter; -}

Effect:

iOS UIButton how the text on the piece on the

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.