首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

iOS开发-舒尔特表

周末闲来无事,看一个概念,挺有意思的,舒尔特表,网上也有很多人写过类似的Demo,本人闲来无事也写了一下,舒尔特表听起来很高大上的样子,不过本人的理解就是一个正方形的矩阵中放的各种小格子,可以是字母,数字或者说是文字,舒尔特表可以通过动态的练习锻炼视神经末梢。心理学上用此表来研究和发展心理感知的速度,其中包括视觉定向搜索运动的速度。培养注意力集中、分配、控制能力;拓展视幅;加快视频;提高视觉的稳定性、辨别力、定向搜索能力。练习的时间越长,看表所需的时间会越短。随着练习的深入,眼球的末梢视觉能力提高,不仅初学者可以有效地拓展视幅,加快阅读节奏,锻炼眼睛快速认读;而且对于进入提高阶段之后,同时拓展纵横视幅,达到一目十行、一目一页非常有效。每表按字符顺序,迅速找全所有的字符,平均1个字符用1秒钟成绩为优良,即9格用9秒、16格用16秒、25格用25秒。(百度百科) 页面布局 根据上面的概念,大概页面布局就是3*3的九宫格,一般是选择数字练习,也没有特别的多弄弄,Main.storyBoard的布局如下: 需要将所有的按钮弄成一个集合,还有就是所有按钮共用一个事件: 集合演示: 按钮共用事件演示: Demo实现 上面中的界面主要都是数字1,因此需要的一个方法生成一个随机的数组,方法如下,生成一个随机不重复的数组大概的规则就是首先顶一个数组,之后的话,需要将数组打乱,使用随机数随机生成索引即可: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - ( NSArray *)getDataArray{ //需要展示的数组 NSMutableArray *arr=[ NSMutableArray array]; for ( NSInteger i=1; i<10; i++) { [arr addObject:@(i)]; } NSInteger count=[arr count]; //生成随机数组 for ( NSInteger i=0; i<count; i++) { NSInteger index=arc4random()%(count-i)+i; [arr exchangeObjectAtIndex:index withObjectAtIndex:i]; } return arr; } 将数组中的值赋值给页面的按钮: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - ( void )initButtonTitle{ //实例化结果集的可变数组 self .resultArr=[ NSMutableArray array]; NSArray *arr=[ self getDataArray]; for (UIButton *button in self .visionButtons) { NSString *result=[arr[button.tag-1]stringValue]; [button setTitle:result forState:UIControlStateNormal]; //重新开始的时候要重新设置按钮的背景和状态 [button setBackgroundColor:[UIColor yellowColor]]; [button setEnabled: YES ]; } [_timerLabel setText:@ "00:00" ]; self .timer=[ NSTimer scheduledTimerWithTimeInterval:0.1 invocation: nil repeats: YES ]; } 在viewDidLoad启动的时候调用对应的程序: 1 [ self initButtonTitle]; 这个时候看到页面的布局应该是这样的: 做到这一步基本上这个程序完成差不多了,然后就是计时,完成之后统计,闲来看下具体的效果,然后看代码可能会更好一点: 功能基本上就是设置按钮的背景颜色,是否可以点击,计时,清零,弹框,显示之前点击的结果,一步一步的分析: 定义成员变量计时和存储结果: 1 2 3 4 5 @interface ViewController () @property NSMutableArray *resultArr; @property NSTimer *timer; @property NSDate *beginDate; @end 设置定时器: 1 self .timer=[ NSTimer scheduledTimerWithTimeInterval:0.1 invocation: nil repeats: YES ]; 设置按钮的背景颜色和显隐: 1 2 [button setBackgroundColor:[UIColor yellowColor]]; [button setEnabled: YES ]; 统计时间: 1 2 3 NSInteger allTime=[_timer.fireDate timeIntervalSinceDate:_beginDate]; NSString *timeFormat=[ NSString stringWithFormat:@ "%02ld:%02ld" ,allTime/1000,allTime%1000]; [_timerLabel setText:timeFormat]; 判断结果,如果所有的结果是升序的那么是成功的,否则就是失败的: 1 2 3 4 5 6 7 8 9 //判断一个数组是不是升序 - ( BOOL )getArrayAsc:( NSArray *)originalArr{ for ( NSInteger i=0; i<[originalArr count]-1; i++) { if (originalArr[i]>originalArr[i+1]) { return NO ; } } return YES ; } 所有按钮的点击事件如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 - ( IBAction )getResult:( id )sender { UIButton *button=(UIButton *)sender; //设置背景颜色 [button setBackgroundColor:[UIColor greenColor]]; //按钮点击一次就不再点击 [button setEnabled: NO ]; NSInteger value=[[[button titleLabel] text] integerValue]; [ self .resultArr addObject:[ NSNumber numberWithInteger:value]]; //点击第一个按钮之后设置开始时间 if ([ self .resultArr count]==1) { //游戏开始时间 _beginDate=[ NSDate date]; //游戏开始 [_timer fire]; } NSInteger allTime=[_timer.fireDate timeIntervalSinceDate:_beginDate]; NSString *timeFormat=[ NSString stringWithFormat:@ "%02ld:%02ld" ,allTime/1000,allTime%1000]; [_timerLabel setText:timeFormat]; //所有的点击完成之后的调用 if ([ self .resultArr count]==9) { //销毁定时器 [_timer invalidate]; //弹框 NSString *tip; if ([ self getArrayAsc: self .resultArr]) { tip=@ "恭喜你,通过比赛" ; } else { tip=@ "不好意思,比赛失败" ; } //将点击的结果使用逗号进行拼接 NSString *resultStr=[ NSString stringWithFormat:@ "%@" ,[ self .resultArr componentsJoinedByString:@ "," ]]; UIAlertView *alterView=[[UIAlertView alloc] initWithTitle:tip message:resultStr delegate: nil cancelButtonTitle:@ "确定" otherButtonTitles: nil ]; [alterView show]; } } ViewController.m中的代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 // // ViewController.m // TableVision // // Created by keso on 15/1/18. // Copyright (c) 2015年 keso. All rights reserved. // #import "ViewController.h" @interface ViewController () @property NSMutableArray *resultArr; @property NSTimer *timer; @property NSDate *beginDate; @end @implementation ViewController - ( void )viewDidLoad { [ super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [ self initButtonTitle]; // self.timer=[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:nil userInfo:nil repeats:YES]; } - ( void )triggerTime:( NSTimer *)sender{ } - ( void )initButtonTitle{ //实例化结果集的可变数组 self .resultArr=[ NSMutableArray array]; NSArray *arr=[ self getDataArray]; for (UIButton *button in self .visionButtons) { NSString *result=[arr[button.tag-1]stringValue]; [button setTitle:result forState:UIControlStateNormal]; //重新开始的时候要重新设置按钮的背景和状态 [button setBackgroundColor:[UIColor yellowColor]]; [button setEnabled: YES ]; } [_timerLabel setText:@ "00:00" ]; self .timer=[ NSTimer scheduledTimerWithTimeInterval:0.1 invocation: nil repeats: YES ]; } - ( IBAction )oneMore:( id )sender { [ self initButtonTitle]; } - ( NSArray *)getDataArray{ //需要展示的数组 NSMutableArray *arr=[ NSMutableArray array]; for ( NSInteger i=1; i<10; i++) { [arr addObject:@(i)]; } NSInteger count=[arr count]; //生成随机数组 for ( NSInteger i=0; i<count; i++) { NSInteger index=arc4random()%(count-i)+i; [arr exchangeObjectAtIndex:index withObjectAtIndex:i]; } return arr; } - ( IBAction )getResult:( id )sender { UIButton *button=(UIButton *)sender; //设置背景颜色 [button setBackgroundColor:[UIColor greenColor]]; //按钮点击一次就不再点击 [button setEnabled: NO ]; NSInteger value=[[[button titleLabel] text] integerValue]; [ self .resultArr addObject:[ NSNumber numberWithInteger:value]]; //点击第一个按钮之后设置开始时间 if ([ self .resultArr count]==1) { //游戏开始时间 _beginDate=[ NSDate date]; //游戏开始 [_timer fire]; } NSInteger allTime=[_timer.fireDate timeIntervalSinceDate:_beginDate]; NSString *timeFormat=[ NSString stringWithFormat:@ "%02ld:%02ld" ,allTime/1000,allTime%1000]; [_timerLabel setText:timeFormat]; //所有的点击完成之后的调用 if ([ self .resultArr count]==9) { //销毁定时器 [_timer invalidate]; //弹框 NSString *tip; if ([ self getArrayAsc: self .resultArr]) { tip=@ "恭喜你,通过比赛" ; } else { tip=@ "不好意思,比赛失败" ; } //将点击的结果使用逗号进行拼接 NSString *resultStr=[ NSString stringWithFormat:@ "%@" ,[ self .resultArr componentsJoinedByString:@ "," ]]; UIAlertView *alterView=[[UIAlertView alloc] initWithTitle:tip message:resultStr delegate: nil cancelButtonTitle:@ "确定" otherButtonTitles: nil ]; [alterView show]; } } - ( void )didReceiveMemoryWarning { [ super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } //判断一个数组是不是升序 - ( BOOL )getArrayAsc:( NSArray *)originalArr{ for ( NSInteger i=0; i<[originalArr count]-1; i++) { if (originalArr[i]>originalArr[i+1]) { return NO ; } } return YES ; } @end 本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4232605.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

打造IOS移动渗透测试平台

是否要越狱,我纠结了很久。Android平台上有很好的图形化黑客工具dsploit和zANTI。东哥从来没有用过Android系统,就不做过多评价。在触屏上敲命令行是一件非常痛苦的事情。 本着生命不息,折腾不止的精神。 用黑哥的话说“整就牛!” ---------------------------------------------------------------------- 首先越狱 安装OpenSSH,修改默认密码(iPhone默认root/alpine) 安装BigBoss Recommendation tools,几乎所有流行的黑客工具都可以在 BigBoss Recommendation tools这个包中找到。 安装: MobileTerminal,它能够让你在设备上直接运行命令行。 ------------------------------------------------------------------------------------------------------ 现在基本环境已经搭建好,今天先安装metasploit,建议用电脑ssh手机安装。 下载ruby环境 wget http://apt.saurik.com/cydia/debs/ruby_1.8.6-p111-5_iphoneos-arm.deb wget http://apt.saurik.com/cydia/debs/rubygems_1.2.0-3_iphoneos-arm.deb 安装ruby dpkg -i ruby_1.8.6-p111-5_iphoneos-arm.deb dpkg -i rubygems_1.2.0-3_iphoneos-arm.deb 安装metasploit git clone git://github.com/rapid7/metasploit-framework 本文转自文东会博客51CTO博客,原文链接http://blog.51cto.com/hackerwang/1607840如需转载请自行联系原作者 谢文东666

优秀的个人博客,低调大师

iOS图像处理之绘制直线

-(void)drawLine:(CGPoint)fromPnt toPoint:(CGPoint)toPnt{ float xScale = theImageView.image.size.width/theImageView.frame.size.width; float yScale = theImageView.image.size.height/theImageView.frame.size.height; UIGraphicsBeginImageContext(theImageView.image.size); [theImageView.image drawInRect:CGRectMake(0, 0, theImageView.image.size.width, theImageView.image.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapSquare); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0*[self returnMax:xScale withNumber:yScale]); CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), fromPnt.x*xScale, fromPnt.y*yScale); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), toPnt.x*xScale, toPnt.y*yScale); CGContextStrokePath(UIGraphicsGetCurrentContext()); theImageView.image=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } 本文转自 卓行天下 51CTO博客,原文链接:http://blog.51cto.com/9951038/1772572,如需转载请自行联系原作者

优秀的个人博客,低调大师

IOS用CGContextRef画各种图形

//覆盖drawRect方法,你可以在此自定义绘画和动画 -(void)drawRect:(CGRect)rect { //AnopaquetypethatrepresentsaQuartz2Ddrawingenvironment. //一个不透明类型的Quartz2D绘画环境,相当于一个画布,你可以在上面任意绘画 CGContextRefcontext=UIGraphicsGetCurrentContext(); /*写文字*/ CGContextSetRGBFillColor(context,1,0,0,1.0);//设置填充颜色 UIFont*font=[UIFontboldSystemFontOfSize:15.0];//设置 [@"画圆:"drawInRect:CGRectMake(10,20,80,20)withFont:font]; [@"画线及孤线:"drawInRect:CGRectMake(10,80,100,20)withFont:font]; [@"画矩形:"drawInRect:CGRectMake(10,120,80,20)withFont:font]; [@"画扇形和椭圆:"drawInRect:CGRectMake(10,160,110,20)withFont:font]; [@"画三角形:"drawInRect:CGRectMake(10,220,80,20)withFont:font]; [@"画圆角矩形:"drawInRect:CGRectMake(10,260,100,20)withFont:font]; [@"画贝塞尔曲线:"drawInRect:CGRectMake(10,300,100,20)withFont:font]; [@"图片:"drawInRect:CGRectMake(10,340,80,20)withFont:font]; /*画圆*/ //边框圆 CGContextSetRGBStrokeColor(context,1,1,1,1.0);//画笔线的颜色 CGContextSetLineWidth(context,1.0);//线的宽度 //voidCGContextAddArc(CGContextRefc,CGFloatx,CGFloaty,CGFloatradius,CGFloatstartAngle,CGFloatendAngle,intclockwise)1弧度=180°/π(≈57.3°)度=弧度×180°/π360°=360×π/180=2π弧度 //x,y为圆点坐标,radius半径,startAngle为开始的弧度,endAngle为结束的弧度,clockwise0为顺时针,1为逆时针。 CGContextAddArc(context,100,20,15,0,2*PI,0);//添加一个圆 CGContextDrawPath(context,kCGPathStroke);//绘制路径 //填充圆,无边框 CGContextAddArc(context,150,30,30,0,2*PI,0);//添加一个圆 CGContextDrawPath(context,kCGPathFill);//绘制填充 //画大圆并填充颜 UIColor*aColor=[UIColorcolorWithRed:1green:0.0blue:0alpha:1]; CGContextSetFillColorWithColor(context,aColor.CGColor);//填充颜色 CGContextSetLineWidth(context,3.0);//线的宽度 CGContextAddArc(context,250,40,40,0,2*PI,0);//添加一个圆 //kCGPathFill填充非零绕数规则,kCGPathEOFill表示用奇偶规则,kCGPathStroke路径,kCGPathFillStroke路径填充,kCGPathEOFillStroke表示描线,不是填充 CGContextDrawPath(context,kCGPathFillStroke);//绘制路径加填充 /*画线及孤线*/ //画线 CGPointaPoints[2];//坐标点 aPoints[0]=CGPointMake(100,80);//坐标1 aPoints[1]=CGPointMake(130,80);//坐标2 //CGContextAddLines(CGContextRefc,constCGPointpoints[],size_tcount) //points[]坐标数组,和count大小 CGContextAddLines(context,aPoints,2);//添加线 CGContextDrawPath(context,kCGPathStroke);//根据坐标绘制路径 //画笑脸弧线 //左 CGContextSetRGBStrokeColor(context,0,0,1,1);//改变画笔颜色 CGContextMoveToPoint(context,140,80);//开始坐标p1 //CGContextAddArcToPoint(CGContextRefc,CGFloatx1,CGFloaty1,CGFloatx2,CGFloaty2,CGFloatradius) //x1,y1跟p1形成一条线的坐标p2,x2,y2结束坐标跟p3形成一条线的p3,radius半径,注意,需要算好半径的长度, CGContextAddArcToPoint(context,148,68,156,80,10); CGContextStrokePath(context);//绘画路径 //右 CGContextMoveToPoint(context,160,80);//开始坐标p1 //CGContextAddArcToPoint(CGContextRefc,CGFloatx1,CGFloaty1,CGFloatx2,CGFloaty2,CGFloatradius) //x1,y1跟p1形成一条线的坐标p2,x2,y2结束坐标跟p3形成一条线的p3,radius半径,注意,需要算好半径的长度, CGContextAddArcToPoint(context,168,68,176,80,10); CGContextStrokePath(context);//绘画路径 //右 CGContextMoveToPoint(context,150,90);//开始坐标p1 //CGContextAddArcToPoint(CGContextRefc,CGFloatx1,CGFloaty1,CGFloatx2,CGFloaty2,CGFloatradius) //x1,y1跟p1形成一条线的坐标p2,x2,y2结束坐标跟p3形成一条线的p3,radius半径,注意,需要算好半径的长度, CGContextAddArcToPoint(context,158,102,166,90,10); CGContextStrokePath(context);//绘画路径 //注,如果还是没弄明白怎么回事,请参考:http://donbe.blog.163.com/blog/static/138048021201052093633776/ /*画矩形*/ CGContextStrokeRect(context,CGRectMake(100,120,10,10));//画方框 CGContextFillRect(context,CGRectMake(120,120,10,10));//填充框 //矩形,并填弃颜色 CGContextSetLineWidth(context,2.0);//线的宽度 aColor=[UIColorblueColor];//blue蓝色 CGContextSetFillColorWithColor(context,aColor.CGColor);//填充颜色 aColor=[UIColoryellowColor]; CGContextSetStrokeColorWithColor(context,aColor.CGColor);//线框颜色 CGContextAddRect(context,CGRectMake(140,120,60,30));//画方框 CGContextDrawPath(context,kCGPathFillStroke);//绘画路径 //矩形,并填弃渐变颜色 //关于颜色参考http://blog.sina.com.cn/s/blog_6ec3c9ce01015v3c.html //http://blog.csdn.net/reylen/article/details/8622932 //第一种填充方式,第一种方式必须导入类库quartcore并#import<QuartzCore/QuartzCore.h>,这个就不属于在context上画,而是将层插入到view层上面。那么这里就设计到QuartzCore图层编程了。 CAGradientLayer*gradient1=[CAGradientLayerlayer]; gradient1.frame=CGRectMake(240,120,60,30); gradient1.colors=[NSArrayarrayWithObjects:(id)[UIColorwhiteColor].CGColor, (id)[UIColorgrayColor].CGColor, (id)[UIColorblackColor].CGColor, (id)[UIColoryellowColor].CGColor, (id)[UIColorblueColor].CGColor, (id)[UIColorredColor].CGColor, (id)[UIColorgreenColor].CGColor, (id)[UIColororangeColor].CGColor, (id)[UIColorbrownColor].CGColor,nil]; [self.layerinsertSublayer:gradient1atIndex:0]; //第二种填充方式 CGColorSpaceRefrgb=CGColorSpaceCreateDeviceRGB(); CGFloatcolors[]= { 1,1,1,1.00, 1,1,0,1.00, 1,0,0,1.00, 1,0,1,1.00, 0,1,1,1.00, 0,1,0,1.00, 0,0,1,1.00, 0,0,0,1.00, }; CGGradientRefgradient=CGGradientCreateWithColorComponents (rgb,colors,NULL,sizeof(colors)/(sizeof(colors[0])*4));//形成梯形,渐变的效果 CGColorSpaceRelease(rgb); //画线形成一个矩形 //CGContextSaveGState与CGContextRestoreGState的作用 /* CGContextSaveGState函数的作用是将当前图形状态推入堆栈。之后,您对图形状态所做的修改会影响随后的描画操作,但不影响存储在堆栈中的拷贝。在修改完成后,您可以通过CGContextRestoreGState函数把堆栈顶部的状态弹出,返回到之前的图形状态。这种推入和弹出的方式是回到之前图形状态的快速方法,避免逐个撤消所有的状态修改;这也是将某些状态(比如裁剪路径)恢复到原有设置的唯一方式。 */ CGContextSaveGState(context); CGContextMoveToPoint(context,220,90); CGContextAddLineToPoint(context,240,90); CGContextAddLineToPoint(context,240,110); CGContextAddLineToPoint(context,220,110); CGContextClip(context);//context裁剪路径,后续操作的路径 //CGContextDrawLinearGradient(CGContextRefcontext,CGGradientRefgradient,CGPointstartPoint,CGPointendPoint,CGGradientDrawingOptionsoptions) //gradient渐变颜色,startPoint开始渐变的起始位置,endPoint结束坐标,options开始坐标之前or开始之后开始渐变 CGContextDrawLinearGradient(context,gradient,CGPointMake (220,90),CGPointMake(240,110), kCGGradientDrawsAfterEndLocation); CGContextRestoreGState(context);//恢复到之前的context //再写一个看看效果 CGContextSaveGState(context); CGContextMoveToPoint(context,260,90); CGContextAddLineToPoint(context,280,90); CGContextAddLineToPoint(context,280,100); CGContextAddLineToPoint(context,260,100); CGContextClip(context);//裁剪路径 //说白了,开始坐标和结束坐标是控制渐变的方向和形状 CGContextDrawLinearGradient(context,gradient,CGPointMake (260,90),CGPointMake(260,100), kCGGradientDrawsAfterEndLocation); CGContextRestoreGState(context);//恢复到之前的context //下面再看一个颜色渐变的圆 CGContextDrawRadialGradient(context,gradient,CGPointMake(300,100),0.0,CGPointMake(300,100),10,kCGGradientDrawsBeforeStartLocation); /*画扇形和椭圆*/ //画扇形,也就画圆,只不过是设置角度的大小,形成一个扇形 aColor=[UIColorcolorWithRed:0green:1blue:1alpha:1]; CGContextSetFillColorWithColor(context,aColor.CGColor);//填充颜色 //以10为半径围绕圆心画指定角度扇形 CGContextMoveToPoint(context,160,180); CGContextAddArc(context,160,180,30,-60*PI/180,-120*PI/180,1); CGContextClosePath(context); CGContextDrawPath(context,kCGPathFillStroke);//绘制路径 //画椭圆 CGContextAddEllipseInRect(context,CGRectMake(160,180,20,8));//椭圆 CGContextDrawPath(context,kCGPathFillStroke); /*画三角形*/ //只要三个点就行跟画一条线方式一样,把三点连接起来 CGPointsPoints[3];//坐标点 sPoints[0]=CGPointMake(100,220);//坐标1 sPoints[1]=CGPointMake(130,220);//坐标2 sPoints[2]=CGPointMake(130,160);//坐标3 CGContextAddLines(context,sPoints,3);//添加线 CGContextClosePath(context);//封起来 CGContextDrawPath(context,kCGPathFillStroke);//根据坐标绘制路径 /*画圆角矩形*/ floatfw=180; floatfh=280; CGContextMoveToPoint(context,fw,fh-20);//开始坐标右边开始 CGContextAddArcToPoint(context,fw,fh,fw-20,fh,10);//右下角角度 CGContextAddArcToPoint(context,120,fh,120,fh-20,10);//左下角角度 CGContextAddArcToPoint(context,120,250,fw-20,250,10);//左上角 CGContextAddArcToPoint(context,fw,250,fw,fh-20,10);//右上角 CGContextClosePath(context); CGContextDrawPath(context,kCGPathFillStroke);//根据坐标绘制路径 /*画贝塞尔曲线*/ //二次曲线 CGContextMoveToPoint(context,120,300);//设置Path的起点 CGContextAddQuadCurveToPoint(context,190,310,120,390);//设置贝塞尔曲线的控制点坐标和终点坐标 CGContextStrokePath(context); //三次曲线函数 CGContextMoveToPoint(context,200,300);//设置Path的起点 CGContextAddCurveToPoint(context,250,280,250,400,280,300);//设置贝塞尔曲线的控制点坐标和控制点坐标终点坐标 CGContextStrokePath(context); /*图片*/ UIImage*image=[UIImageimageNamed:@"apple.jpg"]; [imagedrawInRect:CGRectMake(60,340,20,20)];//在坐标中画出图片 //[imagedrawAtPoint:CGPointMake(100,340)];//保持图片大小在point点开始画图片,可以把注释去掉看看 CGContextDrawImage(context,CGRectMake(100,340,20,20),image.CGImage);//使用这个使图片上下颠倒了,参考http://blog.csdn.net/koupoo/article/details/8670024 //CGContextDrawTiledImage(context,CGRectMake(0,0,20,20),image.CGImage);//平铺图 } @end 用法: CustomView*customView=[[CustomViewalloc]initWithFrame:CGRectMake(0,0,320,self.view.frame.size.height)]; [self.viewaddSubview:customView]; 本文转自 卓行天下 51CTO博客,原文链接:http://blog.51cto.com/9951038/1866003,如需转载请自行联系原作者

优秀的个人博客,低调大师

ios32---线程的状态

// // ViewController.m // 04-了解-线程的状态 // // 创建线程是处于新建状态,start是就绪状态,会放入到可调度线程池里面(cpu看线程是否可以调用,是看线程是否在可调度线程池里面),cpu调度他的时候就会进入运行状态,当这个线程的时间片用完之后,进入就绪状态。所以调用了start方法之后,线程会在运行状态和就绪状态之间进行来回的切换。当线程调用sleep方法时候会进入阻塞状态,进入阻塞状态的线程是不可以工作的,进入阻塞状态时候线程会从可调度线程池里面移除出来到内存里面。此时这个线程还存在只不过cpu不会调用他而已,当sleep时间到了之后,会又移入可调度线程池中进入就绪状态,当cpu调用的时候又会进入运行状态。 // 当线程里面的任务执行完或者异常退出了之后进入死亡状态,死亡会移除可调用线程池,并且从内存释放,不会做任何事情不要想着重新启动线程。 #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { //1.创建线程,新建状态, NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(task) object:nil]; //2.启动线程,就绪状态,放入可执行线程池里面。<---->运行 [thread start]; } -(void)run //run方法执行完毕是死亡状态。 { NSLog(@"run----%@",[NSThread currentThread]); //阻塞线程 [NSThread sleepForTimeInterval:2.0];//睡2秒,进入阻塞状态,移除可执行线程池。不能执行任何操作。 [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:3.0]];//睡3秒,进入阻塞状态,移除可执行线程池。不能执行任何操作。 NSLog(@"end---"); } -(void)task { for (NSInteger i = 0; i<100 ;i++) { NSLog(@"%zd---%@",i,[NSThread currentThread]); if (i == 20) { [NSThread exit]; //退出当前线程,死亡状态。不要想着重新启动线程。 break; //break退出任务,表示任务已经执行完毕,线程也死亡了。 } } } @end 本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/7491262.html,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册
修改密码
忘记密码