随笔分类 - IOS(Objective-C)
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 @property (weak, nonatomic) IBOutlet UIView *customView; 5 6 @end 7 8 @impleme...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 @property (weak, nonatomic) IBOutlet UIImageView *iconView; 5 6 @end 7 8 @impl...
阅读全文
摘要:1 // 1.创建手势识别器 2 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] init]; 3 // 1.1设置长按手势识别器的属性 4 // ...
阅读全文
摘要:1 - (void)viewDidLoad 2 { 3 [super viewDidLoad]; 4 5 // 向上 6 UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] ini...
阅读全文
摘要:一次完整的触摸事件的传递响应的过程UIAppliction --> UIWiondw -->递归找到最适合处理事件的控件控件调用touches方法-->判断是否实现touches方法-->没有实现默认会将事件传递给上一个响应者-->找到上一个响应者1.响应者链条:由很多响应者链接在一起组合起来的一个...
阅读全文
摘要:发生触摸事件后,系统会将该事件加入到一个由UIApplication管理的事件队列中UIApplication会从事件队列中取出最前面的事件并将事件分发下去以便处理,通常先发送给应用程序的主窗口(keyWindow)主窗口会在市图层次结构中找到一个最合适的视图来处理触摸事件找到合适的视图控件后,就会...
阅读全文
摘要:1 #import 2 @class NJLockView; 3 4 @protocol NJLockViewDelegate 5 6 - (void)lockViewDidClick:(NJLockView *)lockView andPwd:(NSString *)pwd;...
阅读全文
摘要:1 @interface NJView () 2 3 @property (nonatomic, strong) NSMutableArray *paths; 4 5 @end 6 7 @implementation NJView 8 9 - (NSMutableArray *)paths...
阅读全文
摘要:1 @interface NJView () 2 /** 3 * 定义一个大数组(大数组中保存小数组, 每一个小数组保存一条直线所有的点) 4 */ 5 @property (nonatomic, strong) NSMutableArray *totalPoints; 6 ...
阅读全文
摘要:1 - (IBAction)captureView:(UIButton *)sender { 2 3 // 延迟1 ~2 秒之后再截屏 4 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NS...
阅读全文
摘要:1 // 当手指在view上移动的时候调用 2 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 3 { 4 5 UITouch *touch = [touches anyObject]; 6 ...
阅读全文
摘要:1 #import 2 3 @interface UIImage (NJ) 4 /** 5 * 生成头像 6 * 7 * @param icon 头像图片名称 8 * @param border 头像边框大小 9 * @param color 头像边框的颜色10 *1...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // 1.获取上下文 4 CGContextRef ctx = UIGraphicsGetCurrentContext(); 5 6 // 2.创建路径(一个path就代表一条路径) 7 ...
阅读全文
摘要:1 @implementation NJView 2 3 /* 4 -(void)awakeFromNib 5 { 6 7 NSLog(@"awakeFromNib"); 8 // 创建CADisplayLink, 默认每秒60次 9 CADisplayLink *di...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // Drawing code 4 5 // 画圆, 以便于以后指定可以显示内容范围 6 CGContextRef ctx = UIGraphicsGetCurrentContext();...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // 画四边形 4 CGContextRef ctx = UIGraphicsGetCurrentContext(); 5 6 // 保存上下文 7 CGContextSaveGS...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // 获取上下文 4 CGContextRef ctx = UIGraphicsGetCurrentContext(); 5 6 // 保存一份最纯洁的图形上下文 7 // 调用一次该方法...
阅读全文
摘要:// controllerX,controllerY是弧形起始点的坐标,endX,endY是结束点的坐标CGContextAddQuadCurveToPoint(ctx, controllerX, controllerY, endX, endY);
阅读全文
摘要:// 1.获取上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); // 2.画饼状图 // 画线 CGContextMoveToPoint(ctx, 100, 100); CGContextAddLineT...
阅读全文
摘要:1 // 画圆弧 2 // 1.获取上下文 3 CGContextRef ctx = UIGraphicsGetCurrentContext(); 4 // 2.画圆弧 5 // x/y 圆心 6 // radius 半径 7 // start...
阅读全文