ios绘制方法

在UIView的子类中,重写drawRect方法

- (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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值