#import "MyView.h" @implementation MyView { CGContextRef context;//UIGraphicsGetCurrentContext(); NSMutableArray *array ; } - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } /**/ // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code [self drawTab]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ if(array == nil){ array = [[NSMutableArray alloc]initWithCapacity:10]; } UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; [array addObject:[NSValue valueWithCGPoint:point]]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; [array addObject:[NSValue valueWithCGPoint:point]]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; [array addObject:[NSValue valueWithCGPoint:point]]; [self setNeedsDisplay]; } -(void) drawTab { context = UIGraphicsGetCurrentContext(); NSValue *value = nil; for(int i=0;i<array.count;i++){ value = [array objectAtIndex:i]; CGPoint point ; [value getValue:&point]; if(i==0){ CGContextBeginPath(context); CGContextMoveToPoint(context,point.x ,point.y); }else if(i == array.count-1){ CGContextAddLineToPoint(context, point.x, point.y); CGContextDrawPath(context, kCGPathStroke); }else { CGContextAddLineToPoint(context, point.x, point.y); } } } @end
相关推荐
一句代码设置UIView及其子类的badgeValue,默认右上角显示 cocoaChina 上传代码比较麻烦,如果有什么问题或者添加什么功能,欢迎大家去我简书留言http://www.jianshu.com/p/497b33250ec1 喜欢的话可以关注我,...
UIView-Positioning, 在UIView对象中,基于简单属性的框架属性设置 uiview定位收费 UIView Positioning 是一个快速扩展,它提供简单的shorthand 方法,以方便的方式定义任何UIView对象的框架属性( 宽度,高度,x,y ...
通用的上下拉刷新,支持UIView、UIScrollView。。。
UIView 动画 UIView动画
ios中关于uiview
作者sSegev,源码SSAlphaPass,SSAlphaPass 可在你当前的视图下传递触摸事件给 UIView\UIButton,但前提是你的像素 alpha 通道应该为0(像素是透明的)。这个方案比单纯忽视掉顶层视图要好,因为你仍然可以在 UIView...
UIView AutoLayout ,UIView AutoLayout 是 UIView 的分类,实现了自动布局限制的简单接口。 T...
UIView+Extension 对view的一个扩展
可以创建一个带有圆角和阴影的uiview
基于UIView扩展的类目,用于设置上下左右圆角,可设置单边圆角,也可设置为圆形 github地址:https://github.com/LQQZYY/UIViewCornerDemo 喜欢的话就给颗星支持一下,感谢!
主要介绍了IOS设置UIView的边框为圆角的相关资料,需要的朋友可以参考下
1、将UIView 保存为图片,按照给定的scale 2、stackoverflow参照 3、保存的图片为依据scale,亲测
详细讲解UIView的生命循环周期,对开发者有更好的启发作用,深层次了解程序运行的流程。
+ (UIView *_Nullable)az_gradientViewWithColors:(NSArray*> *_Nullable)colors locations:(NSArray*> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint; - (void)az_...
为UIView添加圆角扩展
在开发一个项目时,需要刷新一个UITableView的数据,看到腾讯新闻的那种下拉...提示用户松开进行数据的刷新,当用户松开之后,触发scrollViewDidEndDragging事件,进行数据刷新,当刷新完毕之后,将UIView的位置复原。
已封装好的实现渐变的UIView,只需传入渐变开始值和结束值就可直接使用。有四种渐变方向可选
文章简介:http://www.jianshu.com/p/f18eb84e213f 最新代码地址:https://github.com/liuxinixn/LXViewShadowPath
简单的把UIView转化为UIImage,大家可以看下。