Jul. 14th, 2024
2024年 6月 9日

Post: iOS 入门 012: transform

iOS 入门 012: transform

Published 12:04 Apr 13, 2012.

Created by @ezra. Categorized in #Programming, and tagged as #iOS.

Source format: Markdown

Table of Content

transform 形变属性

  • 控件的形变属性 (可以设置旋转角度、比例缩放、平移等属性)

  • UIView一次只能应用一个形变属性

  • 设置transfrom会改变UIView的frame属性,但不会改变bounds属性

  • CGAffineTransformMakeScale相对UIView的初始状态进行形变

  • CGAffineTransformScale相对UIView的当前状态进行形变

Rotate 旋转:

  • CGAffineTransformMakeRotation(CGFloat sx, CGFloat sy)

  • CGAffineTransformRotate(CGAffineTransform t, CGFloat sx, CGFloat sy)


CGAffineTransform  transfromMake= CGAffineTransformMakeRotation(M_PI_4);
CGAffineTransform transfrom= CGAffineTransformRotate(_subView.transform, M_PI_4);
[_view setTransform:transform];
//择角度的参数是弧度值,弧度值是浮点数,180角度对应的弧度是PI,90 = PI/2;

Scale 缩放

  • CGAffineTransformScale(CGAffineTransform t, CGFloat sx, CGFloat sy)

  • CGAffineTransformMakeScale(CGFloat sx, CGFloat sy)

Translation 平移

  • CGAffineTransformTranslation(CGAffineTransform t, CGFloat tx,CGFloat ty)

  • CGAffineTransformMakeTranslation(CGFloat tx,CGFloat ty)

Pinned Message
I'm looking for a SOFTWARE PROJECT DIRECTOR / SOFTWARE R&D DIRECTOR position in a fresh and dynamic company. I would like to gain the right experience and extend my skills while working in great teams and big projects.
Feel free to contact me.
For more information, please view online résumé or download PDF
本人正在寻求任职 软件项目经理 / 软件技术经理 岗位的机会, 希望加⼊某个新鲜⽽充满活⼒的公司。
如有意向请随时 与我联系
更多信息请 查阅在线简历下载 PDF