ios绘制方法
2014-07-30 15:52
225 查看
在UIView的子类中,重写drawRect方法
画文字
UIView动画
我创建了一个QQ群,希望大家能本着互联网开放的心态,将遇到的问题和经验在群里分享,大家互相交流心得,共同提高。
群号:77311380
- (void)drawRect:(CGRect)rect { //画矩形 CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 5.0); CGContextSetStrokeColorWithColor(context, [[UIColor blueColor] CGColor]); //以此为起点 CGContextMoveToPoint(context, rect.origin.x, rect.origin.y); //画四条线,以上一个点为起点,设置线终点 CGContextAddLineToPoint(context, rect.size.width, rect.origin.y); CGContextAddLineToPoint(context, rect.size.width, rect.size.height); CGContextAddLineToPoint(context, rect.origin.x, rect.size.height); CGContextAddLineToPoint(context, rect.origin.x, rect.origin.y); CGContextStrokePath(context); }
画文字
- (void)drawRect:(CGRect)rect { //画文字 UIFont *font = [UIFont systemFontOfSize:8]; //在指定x,y点位置画文字,宽度为18 NSString* str = @"在指定x,y点位置画文字,宽度为18"; [str drawAtPoint:CGPointMake(20, 20) withAttributes:@{NSFontAttributeName: font,NSForegroundColorAttributeName:[UIColor redColor]}]; }
UIView动画
-(void)animationImageView { UIImageView* animationImageView = [[UIImageView alloc] initWithFrame:self.view.frame]; animationImageView.animationImages = @[[UIImage imageNamed:@"loading-1.png"],[UIImage imageNamed:@"loading-2.png"],[UIImage imageNamed:@"loading-3.png"],[UIImage imageNamed:@"loading-4.png"]]; // imageFrames 是一个图片数组 animationImageView是一个imageview // [UIView setAnimationDelegate:self]; animationImageView.animationDuration = 0.75f; animationImageView.animationRepeatCount = 0; [animationImageView startAnimating]; [self.view addSubview:animationImageView]; }
我创建了一个QQ群,希望大家能本着互联网开放的心态,将遇到的问题和经验在群里分享,大家互相交流心得,共同提高。
群号:77311380
相关文章推荐
- 32.CGBitmapContextCreate 在配备Retina的设备上绘制模糊的 解决方法 iOS截屏模糊
- iOS图形绘制方法汇总及图片处理
- [iOS 绘制虚线] 转: iOS 绘制虚线的三种方法
- iOS上文本绘制的几种方法
- iOS绘制3D饼图的实现方法
- iOS 绘制虚线的三种方法
- iOS开发中使用Quartz2D绘制上下文栈和矩阵的方法
- iOS绘制图形的基本方法
- iOS上文本绘制的几种方法
- iOS学习笔记-058.绘制的多种方法——矩形
- iOS 绘制虚线的三种方法
- iOS 绘制纯圆形样式的image图片的方法
- iOS 中各种折线.曲线.图形绘制方法集锦(折线图.走势图.柱状图.动态曲线图.形状图.划线图)
- iOS绘制虚线方法
- IOS绘制虚线的方法,可以给cell设置虚线分割线
- iOS中利用CAGradientLayer绘制渐变色的方法实例
- iOS 中各种折线.曲线.图形绘制方法集锦(折线图.走势图.柱状图.动态曲线图.形状图.划线图)
- iOS绘制虚线方法【原创】
- iOS中绘制圆形的函数方法
- XCode抓取IOS设备上的单帧OpenGL ES绘制过程的方法