//Created by Shaolin on 15/11/26.//copyright©2015 Young Lin. All rights reserved.//#import "UIPillsViewBackgroundView.h"#defineThe_view_color [Uicolor Whitecolor]ConstCGFloat View_radius =5.0f;ConstCGFloat view_line_width =3.0f;@implementationUipillsviewbackgroundview- (void) DrawRect: (cgrect) rect {[Super Drawrect:rect]; Uibezierpath*roundedrect =[Uibezierpath bezierPathWithRoundedRect:self.bounds Cornerradius:view_radius]; [Roundedrect Addclip]; Roundedrect.linewidth=View_line_width; [The_view_color Setstroke]; [Roundedrect strokewithblendmode:kcgblendmodenormal Alpha:1];}@end
The top code is to draw a rectangle with rounded corners.
Bgpill = [[uipillsviewbackgroundview alloc]initwithframe:cgrectzero];
Bgpill. backgroundcolor = [uicolor clearcolor];
[Bgpill setframe:p Ill. Frame];
Bgpill. userinteractionenabled = NO;
Userinteractionenabled
A Boolean value that determines whether user events is ignored and removed from the event queue.
A Boolean value that determines whether a user-triggered event is ignored by the View object and the View object is removed from the event response queue.
IOS Learning Note--0010 (-(void) DrawRect: (cgrect) rect)