• UI基础_transform


    1. #import "ViewController.h"
    2. typedef enum
    3. {
    4.     ButtonTypeLeft = 1,
    5.     ButtonTypeRight,
    6.     ButtonTypeUp,
    7.     ButtonTypeDown,
    8.     ButtonTypeRotleL,
    9.     ButtonTypeRotleR,
    10.     ButtonTypeScaleUp,
    11.     ButtonTypeScaleDown
    12. }ButtonType;
    13. @interface ViewController ()
    14. @property (strong, nonatomic) IBOutlet UIView *viewMan;
    15.  @end
    1. @implementation ViewController
    2. - (IBAction)buttonDirectionClicked:(UIButton *)sender
    3. {
    4.     //获取屏幕的宽度、高度
    5.     NSInteger screenWidth = self.view.frame.size.width;
    6.     NSInteger screenHeight = self.view.frame.size.height;
    7.     //获取viewMain的位置信息
    8.     CGRect rect = self.viewMan.frame;
    9.     //设置移动的尺寸
    10.     NSInteger offSet = 10;
    11.     switch (sender.tag) {
    12.         case ButtonTypeLeft:
    13.             rect.origin.x -= offSet;
    14.             if (rect.origin.x <= -rect.size.width ) {
    15.                 rect.origin.x = screenWidth;
    16.             }
    17.             break;
    18.         case ButtonTypeRight:
    19.             rect.origin.x += offSet;
    20.             if (rect.origin.x >= screenWidth) {
    21.                 rect.origin.x = -rect.size.width;
    22.             }
    23.             break;
    24.         case ButtonTypeUp:
    25.             rect.origin.y -= offSet;
    26.             if (rect.origin.y <= -rect.size.height) {
    27.                 rect.origin.y = screenHeight;
    28.             }
    29.             break;
    30.         case ButtonTypeDown:
    31.             rect.origin.y += offSet;
    32.             if (rect.origin.y >= screenHeight) {
    33.                 rect.origin.y = -rect.size.height;
    34.             }
    35.             break;
    36.     }
    37.     self.viewMan.frame = rect;
    38. }
    39. - (IBAction)buttonRotale:(UIButton *)sender
    40. {
    41.     CGAffineTransform form = self.viewMan.transform;
    42.     switch (sender.tag) {
    43.         case ButtonTypeRotleL:
    44.             form = CGAffineTransformRotate(form, -M_2_PI/2);
    45.             break;
    46.         case ButtonTypeRotleR:
    47.             form = CGAffineTransformRotate(form, M_2_PI/2);
    48.         default:
    49.             break;
    50.     }
    51.     self.viewMan.transform = form;
    52. }
    53. - (IBAction)buttonScale:(UIButton *)sender
    54. {
    55.     CGAffineTransform form = self.viewMan.transform;
    56.     CGFloat scaleFator = 0.0f;
    57.     switch (sender.tag) {
    58.         case ButtonTypeScaleUp:
    59.             scaleFator = 1.5;
    60.             break;
    61.          case ButtonTypeScaleDown:
    62.             scaleFator = 0.5;
    63.     }
    64.     form = CGAffineTransformScale(form, scaleFator, scaleFator);
    65.     self.viewMan.transform = form;
    66. }
    67. - (void)viewDidLoad {
    68.     [super viewDidLoad];
    69.     // Do any additional setup after loading the view, typically from a nib.
    70. }
    71. - (void)didReceiveMemoryWarning {
    72.     [super didReceiveMemoryWarning];
    73.     // Dispose of any resources that can be recreated.
    74. }
    75. @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  润新知