iOS 旋转
实现一张图片的旋转部分角度显示:
[cpp] view plaincopy
UIImageView image = [[UIImageView alloc]init];
image.frame = CGRectMake(50, 50, 200, 200);
image.image = [UIImage imageNamed:@"460.jpg"];
[self.view addSubview:image];
CGAffineTransform transform= CGAffineTransformMakeRotation(M_PI0.38);
/*关于M_PI
#define M_PI 3.14159265358979323846264338327950288
其实它就是圆周率的值,在这里代表弧度,相当于角度制 0-360 度,M_PI=180度
旋转方向为:顺时针旋转
*/
image.transform = transform;//旋转
效果图:
我们可以因此而实现360度 不停的旋转,利用 NSTimer实现角度的不断变化(每0.01s改变一次角度),从而实现不停旋转
[cpp] view plaincopy
[self.view setBackgroundColor:[UIColor redColor]];//设置背景为红色,效果直观明显
[NSTimer scheduledTimerWithTimeInterval: 0.01 target: self selector:@selector(transformAction) userInfo: nil repeats: YES];
改变角度的方法:
[cpp] view plaincopy
-(void)transformAction {
angle = angle + 0.01;//angle角度 double angle;
if (angle > 6.28) {//大于 M_PI*2(360度) 角度再次从0开始
angle = 0;
}
CGAffineTransform transform=CGAffineTransformMakeRotation(angle);
self.view.transform = transform;
}
iOS 旋转的更多相关文章
- IOS 旋转+缩放(手势识别)
@interface NJViewController ()<UIGestureRecognizerDelegate> @property (weak, nonatomic) IBOutl ...
- 头像修改功能 包含ios旋转图片 但是旋转后没遮罩, 正常图片可以显示遮罩 宽高不规则图片没做控制 遮罩框可以拖动
https://blog.csdn.net/wk767113154/article/details/77989544 参考资料 <template> <div id="p ...
- iOS项目开发中的知识点与问题收集整理①(Part 一)
前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...
- ios开发学习笔记(这里一定有你想要的东西,全部免费)
1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用). 其实在代码里还是可以设置的,那就是删除背景view [ ...
- iOS 开发笔记
1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用) 2,NSDate使用 3,UTTabviewCell 未 ...
- iOS项目开发知识点
前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...
- 【转】IOS开发小技巧
1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现clear Color无法使用). 其实在代码里还是可以设置的,那就是删除背景view [ ...
- iOS项目开发中的知识点与问题收集整理①
前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...
- ios新手开发——toast提示和旋转图片加载框
不知不觉自学ios已经四个月了,从OC语法到app开发,过程虽然枯燥无味,但是结果还是挺有成就感的,在此分享我的ios开发之路中的小小心得~废话不多说,先上我们今天要实现的效果图: 有过一点做APP经 ...
随机推荐
- linux daemon
参考 鸟哥的私房菜 http://linux.vbird.org/linux_basic/0560daemons.php
- HDOJ3743<分治>
题意:求一个排列的逆序数. #include<cstdio> #include<iostream> #include<algorithm> const int ma ...
- UVALive - 4026 Difficult Melody(暴力)
我这个英语学渣又把题给翻译错了……(话说,六级差十分没有过,好心疼T T),题目中说的P和Q都是计算game的个数,我以为是出现的次数,各种wa..后来调整了以后又是各种wa,原来是double型的数 ...
- bootstrap's plugin:sthe usage of carousel
if we want use the carousel.js,we need quote it in the page. sample code: <div id="myCarouse ...
- android 图片拍照图片旋转的处理方式
第一种:String str=path; /** * 读取图片属性:旋转的角度 * * @param path * 图片绝对路径 * @return degree旋转的角度 */ private vo ...
- Mysql笔记3数据库基本操作
1 创建数据库 create database 数据名称 default character set 编码; 2查看常用的编码校验规则 mysql> show character set; 3删 ...
- Chapter 1 First Sight——17
Once I got around the cafeteria, building three was easy to spot. 我一走出自助餐厅,很容易看见建筑三. A large black & ...
- 编写一条sql命令,sql删除没有中文的表
删除包含中文的 和不饱和中文的字段 SHOW create table pages; drop table if exists `film`; CREATE TABLE `film` ( `id` i ...
- Angularjs循环二维数组
<div ng-app> <div ng-controller="test"> <div ng-repeat="links in slide ...
- Nginx反向代理配置文件
server { listen ; server_name ; root E:/Upays/public/; index index.php index.html; log_not_found off ...