-
UI基础_transform
- #import "ViewController.h"
- typedef enum
- {
- ButtonTypeLeft = 1,
- ButtonTypeRight,
- ButtonTypeUp,
- ButtonTypeDown,
- ButtonTypeRotleL,
- ButtonTypeRotleR,
- ButtonTypeScaleUp,
- ButtonTypeScaleDown
- }ButtonType;
- @interface ViewController ()
- @property (strong, nonatomic) IBOutlet UIView *viewMan;
- @end
- @implementation ViewController
- - (IBAction)buttonDirectionClicked:(UIButton *)sender
- {
- //获取屏幕的宽度、高度
- NSInteger screenWidth = self.view.frame.size.width;
- NSInteger screenHeight = self.view.frame.size.height;
- //获取viewMain的位置信息
- CGRect rect = self.viewMan.frame;
- //设置移动的尺寸
- NSInteger offSet = 10;
- switch (sender.tag) {
- case ButtonTypeLeft:
- rect.origin.x -= offSet;
- if (rect.origin.x <= -rect.size.width ) {
- rect.origin.x = screenWidth;
- }
- break;
- case ButtonTypeRight:
- rect.origin.x += offSet;
- if (rect.origin.x >= screenWidth) {
- rect.origin.x = -rect.size.width;
- }
- break;
- case ButtonTypeUp:
- rect.origin.y -= offSet;
- if (rect.origin.y <= -rect.size.height) {
- rect.origin.y = screenHeight;
- }
- break;
- case ButtonTypeDown:
- rect.origin.y += offSet;
- if (rect.origin.y >= screenHeight) {
- rect.origin.y = -rect.size.height;
- }
- break;
- }
- self.viewMan.frame = rect;
- }
- - (IBAction)buttonRotale:(UIButton *)sender
- {
- CGAffineTransform form = self.viewMan.transform;
- switch (sender.tag) {
- case ButtonTypeRotleL:
- form = CGAffineTransformRotate(form, -M_2_PI/2);
- break;
- case ButtonTypeRotleR:
- form = CGAffineTransformRotate(form, M_2_PI/2);
- default:
- break;
- }
- self.viewMan.transform = form;
- }
- - (IBAction)buttonScale:(UIButton *)sender
- {
- CGAffineTransform form = self.viewMan.transform;
- CGFloat scaleFator = 0.0f;
- switch (sender.tag) {
- case ButtonTypeScaleUp:
- scaleFator = 1.5;
- break;
- case ButtonTypeScaleDown:
- scaleFator = 0.5;
- }
- form = CGAffineTransformScale(form, scaleFator, scaleFator);
- self.viewMan.transform = form;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
-
相关阅读:
maven基础依赖外部lib包(依赖钉钉sdk为例)
JVM的内存区域划分
EF6 根据数据库字段说明,生成字段注释
js上传图片,js图片转换为Base64
Jquery用append()方法新增加的元素事件失效
MVC添加区域路由问题
JObject获取JSON格式字符串数据
百度地图WebApi根据地址解析经纬度和根据经纬度解析地址
sqlserver函数根据经纬度计算两点之间的距离
AdminLTE-2.4.0-rc文件添加到项目中报错 错误 1 “tsc.exe”已退出,代码为 1。 M.Website
-
原文地址:https://www.cnblogs.com/xjf125/p/4761395.html
Copyright © 2020-2023
润新知