zoukankan      html  css  js  c++  java
  • 初见IOS的UI之:UI控件的属性frame bounds center 和transform

    这些属性,内部都是结构体:CGRect CGPoint CGFloat

    背景知识:所有的控件都是view的子类,屏幕就是一个大的view;每个view都有个viewController,它是view的管家,每个view对应着一个viewController,来管理view。

    1.  frame & bounds & center

      ========================================

      1> frame可以修改对象的位置和尺寸

      2> bounds可以修改对象的尺寸

      3> center可以修改对象的位置,是对象的中心的x,y坐标

      

      2.首尾式动画

      ========================================

      // beginAnimations表示此后的代码要参与到动画中

      [UIView beginAnimations:nil context:nil];

      // setAnimationDuration用来指定动画持续时间

      [UIView setAnimationDuration:2.0];

      self.headImageView.bounds = rect;

     

      // commitAnimations,将beginAnimation之后的所有动画提交并生成动画

      [UIView commitAnimations];

     

      3. transform属性

      ========================================

      在OC中,通过transform属性可以修改对象的平移、缩放比例和旋转角度

     

      常用的创建transform结构体方法分两大类

     

      1> 创建基于控件初始位置的形变

      CGAffineTransformMakeTranslation

      CGAffineTransformMakeScale

      CGAffineTransformMakeRotation

     

      2> 创建基于transform参数的形变,返回的时当前的坐标值,不需要一直计算,这个比较常用

      所以会多一个参数:就是当前的控件对象;

      CGAffineTransformTranslate

      CGAffineTransformScale

      CGAffineTransformRotate

     

      补充:

      在OC中,所有跟角度相关的数值,都是弧度值,180° = M_PI

      正数表示顺时针旋转

      负数表示逆时针旋转

      提示:由于transform属性可以基于控件的上一次的状态进行叠加形变,例如,先旋转再平移

      因此在实际动画开发中,当涉及位置、尺寸形变效果时,大多修改控件的transform属性,

      而不是frameboundscenter  

  • 相关阅读:
    HeadFirst设计模式之RMI介绍
    HeadFirst设计模式之状态模式
    算法Sedgewick第四版-第1章基础-001递归
    HeadFirst设计模式之组合模式
    HeadFirst设计模式之迭代器模式
    HeadFirst设计模式之模板方法模式
    HeadFirst设计模式之适配器模式
    CentOS-6.5-saltstack-安装
    Swift
    在OC中调用Swift类中定义delegate出现:Property 'delegate' not found on object of type ...
  • 原文地址:https://www.cnblogs.com/cxbblog/p/3742093.html
Copyright © 2011-2022 走看看