Several ways to mix iOS graphics

Source: Internet
Author: User

Recently optimized to upgrade a previously done project, now this issue is nearing the end of today, you can make some time to summarize the most recent projects used in the more picture text mixed display content. Now encountered more than the basic three kinds of graphics and text mix: One is to display the price symbol in the label + price + An internal project units (such as food stamps symbol) + quantity, this is used more in the project; the second is to display a piece of text in the product details + a set of images or a text + an array of pictures to display, This is in the details of the use of a lot, there is a kind of and the second similar, like the Web page of things, there is not much to say, the following is the first two more commonly used in the image of the mixed display of the way;

1, in the label display price unit + price + Item internal unit symbol + quantity of one way; This is a more simple way to find third-party support for image display controls, like Cttextdisplayview-master, from the web. In the Cocoachina or code4app can be searched for, it encapsulates a view type of cell object, support images, text, hyperlinks, @ Someone, etc., you can download it yourself, with a effect or good, powerful, also supports the click effect on the specified text field, and the other way is to use the Uilabel tag to redraw the label, or to achieve the same effect; no more talking about the code directly.

NSString *temstr = [NSString stringwithformat:@ "¥%.2f +", [Price Floatvalue]-[score floatvalue]];

nstextattachment* attach = [[Nstextattachment alloc] init];

Attach.image = [UIImage imagenamed:@ "P gray list food stamps symbol. PNG"];

nsattributedstring* attStr1 = [nsattributedstring Attributedstringwithattachment:attach];

nsmutableattributedstring* attstr = [[Nsmutableattributedstring alloc] initwithattributedstring:attstr1];

nsmutableattributedstring *strmatt = [[Nsmutableattributedstring alloc] initwithstring:temstr];

Insert a paragraph of text in front of the picture

[Attstr Insertattributedstring:strmatt atindex:0];

Append a paragraph of text to a picture

[Attstr appendattributedstring:[[nsattributedstring alloc] initwithstring:[nsstring stringwithformat:@ "%.2f", [ Score Floatvalue]];

Set the size of a picture

Attach.bounds = CGRectMake (0, 0, 8, 9);

Cell.lblrealprice.attributedText = Attstr;

2, in the details of the implementation of the text and the way of the mixed, or a text + a picture as a whole set of display; The front of this need to achieve the dynamic judgment of the height of the image, and then based on the number of images of the dynamic calculation of the overall height and the location of the picture display, Of course, there is a view of the effect of the large map is not described in detail here. The second kind of label, picture can be encapsulated into a cell dynamically determine the text height of each cell + picture whether or not exist;

Several ways to mix iOS graphics

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.