Several ways to cut corners in iOS

Source: Internet
Author: User

These days in the study to the fillet of the method, also found the next online information----------

Cut corners to avoid off-screen rendering as much as possible.

1. Setting fillets directly with the two properties in a layer in the view is simple, but not recommended for performance:

@property (Strong, nonatomic) Iboutlet Uiimageview *imageview;

Self.imageView.layer.cornerRadius = 5;

Self.imageView.layer.masksToBounds = YES;

2. Set the fillet through layer and Bezierpath

-(void) Setlayerandbezierpathcutcircularwithview: (UIView *) view

{

Create Bezierpath and set corners and radii

Uibezierpath *path = [Uibezierpath bezierPathWithRoundedRect:view.bounds byroundingcorners:uirectcornertopleft | Uirectcornertopright| Uirectcornerbottomleft| Uirectcornerbottomright Cornerradii:cgsizemake (5, 5)];

Cashapelayer *layer = [[Cashapelayer alloc] init];

Layer.frame = View.bounds;

Layer.path = path. Cgpath;

View.layer.mask = layer;

}

3. Set the fillet with the graphics and Bezierpath

-(void) Setgraphicscutcirculaywithview: (Uiimageview *) view

{

Uigraphicsbeginimagecontextwithoptions (View.bounds.size, NO, 1.0);

[[Uibezierpath BezierPathWithRoundedRect:view.bounds cornerradius:5] addclip];

[View DrawRect:view.bounds];

View.image = Uigraphicsgetimagefromcurrentimagecontext ();

End

Uigraphicsendimagecontext ();

}

Welcome to the Discussion ~ ~ ~

Several ways to cut corners in iOS

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.