iOS from top one view

Source: Internet
Author: User

ykpopview.m//drawansample////Created by Goshong on 15/9/6.//Copyright (c) 2015 Yinyakun. All rights reserved.//#import "YKPopView.h" #define MENUGAP 7@implementation ykpopview-(instancetype) initWithFrame: (    CGRect) frame {self = [super Initwithframe:frame];    if (self) {self.backgroundcolor = [uicolor Clearcolor]; } return self;} Only override Drawrect:if-perform custom drawing.//an empty implementation adversely affects performance during a    nimation.-(void) DrawRect: (cgrect) Rect {//Drawing code cgfloat width = rect.size.width;    CGFloat height = rect.size.height;        CGFloat radius = 3;    Get Cgcontext, note that Uikit uses a specialized function cgcontextref context = Uigraphicsgetcurrentcontext ();        Move to the initial point cgcontextmovetopoint (context, radius, menugap);    Draws a 1th line and 1th 1/4 arc cgcontextaddlinetopoint (context, Width * 5/6-6,menugap);    Cgcontextaddlinetopoint (Context, Width * 5/6,0);  Cgcontextaddlinetopoint (Context, Width * 5/6 + 6,menugap);  Cgcontextaddlinetopoint (context, Width-radius, menugap);        Cgcontextaddarc (context, Width-radius, radius + menugap, radius, -0.5 * m_pi, 0.0, 0);    Draw 2nd line and 2nd 1/4 Arc cgcontextaddlinetopoint (context, width, height-radius-menugap);        Cgcontextaddarc (context, Width-radius, height-radius-menugap, radius, 0.0, 0.5 * m_pi, 0);    Draw 3rd Line and 3rd 1/4 arc cgcontextaddlinetopoint (context, radius, height-menugap);        Cgcontextaddarc (context, radius, height-radius-menugap, radius, 0.5 * m_pi, M_PI, 0);    Draws a 4th line and 4th 1/4 Arc cgcontextaddlinetopoint (context, 0, radius + menugap);        Cgcontextaddarc (context, radius, radius + menugap, radius, M_PI, 1.5 * m_pi, 0);        Closed path Cgcontextclosepath (context);    [[Uicolor Redcolor] setfill]; Cgcontextdrawpath (context, Kcgpathfill);}

Customize a view.

iOS from top one view

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.