蓝懿ios 技术内容交流和学习心得 11.17

今天是练习日:

一、把模拟器里的view当作图片保存到相册的方法:

1、 创建画布

   UIGraphicsBeginImageContext(self.EditView.bounds.size);

2、把图片渲染到画布中

   [self.EditView.layer renderInContext:UIGraphicsGetCurrentContext()];

3、把图像从画布中取出

   UIImage* image = UIGraphicsGetImageFromCurrentImageContext();

4、结束

   UIGraphicsEndImageContext();

5、把图片保存到相册中

 注:方法image:didFinishSavingWithError:contextInfo:UIImageWriteToSavedPhotosAlbum中有提示,image为要保存的图片名即从画布中取出的图片名,后边nil可以写想要传的参数

   UIImageWriteToSavedPhotosAlbum(image, self,@selector

(image:didFinishSavingWithError:contextInfo:),nil);

}

- (void)image:(UIImage *)imagedidFinishSavingWithError:(NSError*)error contextInfo:(void *)contextInfo{

}

二、控件的相对坐标系转换方法:

1、矩形的:

iv相对于sv的坐标转换为iv相对于view的坐标(新生成的dragIV用到了iv的位置

              CGRect oldFrame =iv.frame;

 

         CGRect newFrame = [self.mySV convertRect:oldFrame toView:self.view];

2、点的:

dragIV的中心点相对于view的坐标转化为相对于EditView的坐标;

 

self.dragIV.center =[self.view convertPoint:self.dragIV.center toView:self.EditView];

动画

   //    frame  bounds  alpha  背景颜色  center  transform(转换)    UIImageView* iv =[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];    iv.image = [UIImage imageNamed:@"8.jpg"];    [self.view addSubview:iv];    //NO.1旋转渐变animateWithDuration(动画持续时间)//    [UIView animateWithDuration:3 animations:^{//        iv.center = CGPointMake(300, 300);//        iv.alpha = .5;//        iv.transform = CGAffineTransformScale(iv.transform, .5, .5);//        //旋转//        iv.transform =CGAffineTransformRotate(iv.transform, 90.0*M_PI/180);//    }];     //NO.2原地向左旋转  completion完成//    [UIView animateWithDuration:3 animations:^{//        iv.transform = CGAffineTransformRotate(iv.transform, 90.0*M_PI/180);//    } completion:^(BOOL finished) {//        [iv removeFromSuperview];//    }];    //NO.3 delay(延迟时间)    [UIView animateWithDuration:3 delay:3 options:UIViewAnimationOptionCurveEaseIn animations:^{        iv.center = CGPointMake(300, 300);    } completion:^(BOOL finished) {        [iv removeFromSuperview];    }];

}

  

    //旋转,左旋    number++;    CGAffineTransform rotate = CGAffineTransformMakeRotation(number / 180.0 * M_PI );    [viewDemo setTransform:rotate];}如果使用此方法连续点击button就可以显示处一点一点的移动效果每次旋转90度的话可以使用一下的代码实现效果-(void)testViewDemo{//旋转,右旋    number = number+90.0;    CGAffineTransform rotate = CGAffineTransformMakeRotation(number / 180.0 * M_PI );    [viewDemo setTransform:rotate];}UIView实现左旋效果//旋转,左旋    number = number-90.0;    CGAffineTransform rotate = CGAffineTransformMakeRotation(number / 180.0 * M_PI );    [viewDemo setTransform:rotate];

学习ios  重要还是要理清楚思路  在做或者看老师代码的时候 自己多想想为什么  不要自己看着就抄       另外还是要推荐一下 蓝懿IOS这个培训机构  和刘国斌老师刘国斌老师还是很有名气的,听朋友说刘老师成立了蓝懿iOS,,老师讲课方式很独特,能够尽量让每个人都能弄明白,有的比较难懂的地方,如果有的地方还是不懂得话,老师会换个其它方法再讲解,这对于我们这些学习iOS的同学是非常好的,多种方式的讲解会理解得更全面,这个必须得给个赞,嘻嘻,还有就是这里的学习环境很好,很安静,可以很安心的学习,安静的环境是学习的基础,小班讲课,每个班20几个学生,学习氛围非常好,每天都学到9点多才离开教室,练习的时间很充裕,而且如果在练习的过程中有什么困难,随时可以向老师求助,不像其它机构,通过视频教学,有的甚至学完之后都看不到讲师本人,问点问题都不方便,这就是蓝懿与其它机构的区别,相信在刘国斌老师的细心指导下,每个蓝懿学员都能找到满意的工作,加油!

                                                                  写博客第三十八天;

                                                                              QQ:565803433​


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值