IOS modifies the rounded corner image. ios modifies the rounded corner image.

Source: Internet
Author: User

IOS modifies the rounded corner image. ios modifies the rounded corner image.

Style

Modifying the rounded corner is generally done by modifying the layer of the view.

/*** Circle ** @ param view */-(void) VC2RoundView :( UIView *) view {// you can enable one of them. layer. masksToBounds = YES; // view. clipsToBounds = YES; view. layer. cornerRadius = CGRectGetWidth (view. frame)/2 ;}

This is totally wrong ..........

Then, I used this method to check the information on the Internet and modify the rounded corner. I even downloaded other people's demos. However, what others do can be normally displayed, and my results won't work, check the differences from the beginning, and then find that they are all code display or do not use xib, so the fixed width and height

 

OK, the effect is achieved, but the fixed width and height are definitely not good for adaptive adaptation. Now the problem is that the view display constraints are correctly set but not loaded correctly, or is the modification of the rounded corner before the constraint adjustment ?, Retry

Add the code for modifying the rounded corner in viewdidload to viewdidappear.

It can be displayed normally, but when displayed, the square is directly displayed as a circle. Looking for the view declaration cycle method, we found a viewDidLayoutSubviews, and re-wrote it here.

OK. It IS DISPLAYED normally. And adaptive.

The problem with this feedback is that the modification to the view layer occurs before the constraint is adjusted. If the layer and the constraint are associated, You Need To debug it properly.

Otherwise, such problems may occur.

 

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.