IOS summaryimplement UIButton text-and-image mixing and display text and images at the same time, iosuibutton

Source: Internet
Author: User

IOS summaryimplement UIButton text-and-image mixing and display text and images at the same time, iosuibutton

Buttons are often used to display text and images at the same time. For example:


We need to define a UIButton subclass.


Implementation File

-(Id) initWithFrame :( CGRect) frame

{

Self = [super initWithFrame: frame];

If (self ){

// You can adjust it as needed

Self. titleLabel. textAlignment = NSTextAlignmentRight;

Self. titleLabel. font = [UIFontsystemFontOfSize: 14.0];

Self. imageView. contentMode = UIViewContentModeLeft;

}

Return self;

}

// Override the UIButton method of the parent class


// More button-specific rect settings and return the rect of the text label

-(CGRect) titleRectForContentRect :( CGRect) contentRect

{

CGFloat titleW = contentRect. size. width-30;

CGFloat titleH = contentRect. size. height;

CGFloat titleX = 0;

CGFloat titleY = 0;

ContentRect = (CGRect) {titleX, titleY}, {titleW, titleH }};

Return contentRect;

}


// More button-specific rect settings and returned UIImageView rect

-(CGRect) imageRectForContentRect :( CGRect) contentRect

{

CGFloat imageW = 25;

CGFloat imageH = 25;

CGFloat imageX = contentRect. size. width-26;

CGFloat imageY = 2.5;

ContentRect = (CGRect) {imageX, imageY}, {imageW, imageH }};

Return contentRect;

}


// Use the UIButton subclass

YxpButton * selectAreaButton = [[yxpButtonalloc] initWithFrame: CGRectMake (100, 30)];

[SelectAreaButton setTitle: @ "" forState: UIControlStateNormal];

[SelectAreaButton setImage: [UIImageimageNamed: @ "location"] forState: UIControlStateNormal];

[SelectAreaButton setTitleColor: [UIColorwhiteColor] forState: UIControlStateNormal];

[NavigationBgViewaddSubview: selectAreaButton];


In this way, we can achieve the text mixing of a button.


Insert text into an image in a simple way

I suggest you study the front page more deeply. As long as you fully understand the front page, other web design software can be used quickly. Below are some tips for you to continue to improve.

The following are some of the problems and problems I encountered in designing my personal webpage on the FrontPage98 by myself. I have also found the answers through practice. I have sorted out the problems below, so I hope I can communicate with many computer enthusiasts.

1. After one row, I press the Enter key to jump to the section on the other line. Is there a good way to control the line spacing?

You can press the [Shift] key after the end of a paragraph, and press enter to skip to the next paragraph, [Shift + Enter] is a shortcut that controls the relationship between a paragraph and a paragraph.

2. How can I add a background to a piece of text?

First move the cursor to the paragraph to be defined (if there is no hard carriage return between the paragraph, it means to add the same background to the paragraphs), right-click the paragraph, select [style] in [section attribute]. In [color], you can see the background and foreground color, and select [background image. Note: If you press enter after a segment, you can directly press enter to reach another line (separated by a line). You can use the method 1 to Control the segment and paragraph.

3. How to make several pages in a framework have no boundaries?

Select the [framework page attribute] in the [framework] in the total menu. In the last one, we will see the option [framework]. You can remove the hook of the [display boundary] item, when browsing through a browser, you will not see any trace between pages.

4. How to overlap two images?

One way is to add a background to a paragraph or paragraph, and then insert an image into the paragraph. The second method is to draw a table, place the image or text in it, move the cursor to the table, right-click the table, and select [table attributes]. change [border line width], [Cell edge, spacing] in [layout] to [0], select [use background image] in the [custom background] to overlap two or more images.

5. What is the role of the FrontPage98 title ad manager?

The [Title ad manager] of FrontPage98 is used to arrange several images for rotating playback. It can also be used as a super connection mode to connect to another webpage.

6. Why does the page not respond after I use the [title ad manager?

This is actually a Java program application. In the FrontPage98 [browser] state, we can see the effect, but in fact we save the file and will find that the page cannot be normally viewed and displayed, make the page in the [HTML] state, and you will see such a text <applet code = "fprotate. class "codebase =" _ fpclass "......>, this is a file generated in the temporary state. You need to set fprotate. class: copy this file to the webpage directory on your disk (the file is in the x: \ Program Files \ Microsoft FrontPage \ fpclass directory, or you can find it through the Windows Search function ), at the same time, delete the codebase = "_ fpclass" and the page will be browsed normally.

7. Why does my search form have no effect after being uploaded?

Because it requires the support of CGI programs on the server.

8. How to set the counter and pay attention to the book?

CGI programs on the same server are usually provided by some service providers that provide personal homepage space. For example, Netease copies a program provided to a proper webpage location, follow the instructions to change the name you applied for, but note that the counter can only be displayed after the web page is uploaded. In fact, many network service providers that provide free personal space currently use UNIX systems. Therefore, the counters provided under Fp98 are designed for Windows NT, it cannot be used in UNIX.

9. Why is [this page may not be properly previewed because of its...] displayed on some pages in the [browse] status?

Because Microsoft has left the full text in frobtpage9......>

How can I insert a graph into the frontpage so that the word floats above the graph '''?

I suggest you study the front page more deeply. As long as you fully understand the front page, other web design software can be used quickly. Below are some tips for you to continue to improve.

The following are some of the problems and problems I encountered in designing my personal webpage on the FrontPage98 by myself. I have also found the answers through practice. I have sorted out the problems below, so I hope I can communicate with many computer enthusiasts.

1. After one row, I press the Enter key to jump to the section on the other line. Is there a good way to control the line spacing?

You can press the [Shift] key after the end of a paragraph, and press enter to skip to the next paragraph, [Shift + Enter] is a shortcut that controls the relationship between a paragraph and a paragraph.

2. How can I add a background to a piece of text?

First move the cursor to the paragraph to be defined (if there is no hard carriage return between the paragraph, it means to add the same background to the paragraphs), right-click the paragraph, select [style] in [section attribute]. In [color], you can see the background and foreground color, and select [background image. Note: If you press enter after a segment, you can directly press enter to reach another line (separated by a line). You can use the method 1 to Control the segment and paragraph.

3. How to make several pages in a framework have no boundaries?

Select the [framework page attribute] in the [framework] in the total menu. In the last one, we will see the option [framework]. You can remove the hook of the [display boundary] item, when browsing through a browser, you will not see any trace between pages.

4. How to overlap two images?

One way is to add a background to a paragraph or paragraph, and then insert an image into the paragraph. The second method is to draw a table, place the image or text in it, move the cursor to the table, right-click the table, and select [table attributes]. change [border line width], [Cell edge, spacing] in [layout] to [0], select [use background image] in the [custom background] to overlap two or more images.

5. What is the role of the FrontPage98 title ad manager?

The [Title ad manager] of FrontPage98 is used to arrange several images for rotating playback. It can also be used as a super connection mode to connect to another webpage.

6. Why does the page not respond after I use the [title ad manager?

This is actually a Java program application. In the FrontPage98 [browser] state, we can see the effect, but in fact we save the file and will find that the page cannot be normally viewed and displayed, make the page in the [HTML] state, and you will see such a text <applet code = "fprotate. class "codebase =" _ fpclass "......>, this is a file generated in the temporary state. You need to set fprotate. class: copy this file to the webpage directory on your disk (the file is in the x: \ Program Files \ Microsoft FrontPage \ fpclass directory, or you can find it through the Windows Search function ), at the same time, delete the codebase = "_ fpclass" and the page will be browsed normally.

7. Why does my search form have no effect after being uploaded?

Because it requires the support of CGI programs on the server.

8. How to set the counter and pay attention to the book?

CGI programs on the same server are usually provided by some service providers that provide personal homepage space. For example, Netease copies a program provided to a proper webpage location, follow the instructions to change the name you applied for, but note that the counter can only be displayed after the web page is uploaded. In fact, many network service providers that provide free personal space currently use UNIX systems. Therefore, the counters provided under Fp98 are designed for Windows NT, it cannot be used in UNIX.

9. Why is [this page may not be properly previewed because of its...] displayed on some pages in the [browse] status?

Because Microsoft has left the full text in frobtpage9......>

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.