Ios-frame layout floating-point numbers cause alignment issues

Source: Internet
Author: User

First, the problem some needs need to use the button and label, and need to align the same line, such as a cue bar, there is a part of the tip text is not clickable, but some of the text can be clicked and jump. Thus throughSizewithattributes or other system method calculates the string size, and then sets the size of the button to the size of the corresponding title, the label aligns the button, and the size is set to the size of the corresponding text string. In the case of coordinates and size, the font is misaligned:Second, reproduce the problem: Create a button and a label, the coordinates are as follows:<UIButton:0x7c49ac50; frame = (0; 199.131 35.8008); opaque = NO; layer = <calayer:0x7c49adb0>> ; <UILabel:0x7c15efc0; frame = (199.131; 199.131 35.8008); text = ' search. 123 Search '; userinteractionenabled = NO; layer = <_UILabelLayer:0x7c15f230>>  Study found that the Y coordinate of the two view is the same, the output of the background color and not see the two view background area is different, further found that when the value of x, Y is also a floating point, the deviation will be greater, and then try to take the value of the frame through the whole to find two view alignment, such as: third, conclusion The button and label internally handle floating-point coordinates differently, and if you need a different view alignment, and you use the frame layout, make sure that the value of the frame is an integer.

Ios-frame layout floating-point numbers cause alignment issues

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.