UI整理-----part1--UI基础

UI整理:---UI的系统构架是:Core OS核心层,Core Service核心服务层,Media媒体层,Cocoa Touch触摸层---iOS的UI控件创建有两种方式:1.代码创建 2.XIB文件创建---程序的5种状态:1.Notrunning  2.inactive   3.active   4.background   5.suspended    2和3是foreground

1.坐标系和参照系

(1)CGPoint---决定的点是坐标的位置(CGPointMake(<#CGFloatx#>, <#CGFloaty#>)

       CGSize---决定着大小(CGSizeMake(<#CGFloatwidth#>, <#CGFloatheight#>)

       CGRect是point和size的综合决定(CGRectMake(<#CGFloatx#>, <#CGFloaty#>, <#CGFloatwidth#>, <#CGFloatheight#>)

       struct CGRect {

       CGPoint origin;        rect.origin = point

       CGSize size;             rect.size = size;

       };

(2)frame:View在父类View的坐标系统中的位置和大小。

       bounds:View在本地坐标系中的位置和大小。

       center:View的中点在父类坐标系中的位置和大小

       以上3个都是@property类型(@property(nonatomic))

2.UIKit和UIView

(1)UIKit是一个提供了在iOS实现图形事件驱动程序的框架

(2)UIResponder表示一种可以接收触摸屏上的触摸事件的对象

(3)UIView的层次结构被称为“视图树”

(4)subView即子视图、superView即超视图

(5)可以创建一个数组,用来存放子视图-----NSArray *array = [view subViews]

(6)UIButton:

      <1>通过   - (void)setTitle:(nullableNSString *)titleforState:(UIControlState)state;可以设置button

      <2>通过   - (void)addTarget:(nullableid)targetaction:(SEL)actionforControlEvents:(UIControlEvents)controlEvents;给button一个点击功能

      <3>通过 - (void)touchesBegan:(NSSet<UITouch *> *)toucheswithEvent:(UIEvent *)event{}

                   - (void)touchesMoved:(NSSet<UITouch *> *)toucheswithEvent:(UIEvent *)event{}

                   - (void)touchesEnded:(NSSet<UITouch *> *)toucheswithEvent:(UIEvent *)event{}

                   - (void)touchesCancelled:(NSSet<UITouch *> *)toucheswithEvent:(UIEvent *)event{}

                   - (void)touchesEstimatedPropertiesUpdated:(NSSet *)touches{}

                   可以添加一个触摸事件方法

(7)@property (nonatomicgetter=isUserInteractionEnabledBOOLuserInteractionEnabled   设置视图能否响应触摸

(8)alpha和hidden:alpha是调节透明度,属性为浮点类型的值,取值范围从0到1.0,表示从透明到不透明,当前UIView的alpha值会被其所有subview继承。 alpha值会影响到UIView跟其所有subview,alpha具有动画效果。当alpha为0时,跟hidden为YES时效果一样,但是alpha主要用于实现隐藏的动画效果,在动画块中将hidden设置为YES没有动画效果。   Hidden表示UIView是否隐藏,Hidden设置为YES表示 当 前UIView的所有subview也会被隐藏,忽略subview的hidden属性。Hidden只要设置为YES,所有的subview都会隐藏。UIView隐藏之后也会从当前的响应者事件中移除。

(9)UIWindow的三个优先级:normal < StatusBar < alert       window.windowlevel = UIWindowLevelAlert

3. 坐标系统转换:坐标系统变换通过transform属性来改变     1.CGAffineTransformScale  对试图比例缩放    2.CGAffineTransformRotate   对试图做变焦旋转      3.CGAffineTransformTranslate    对试图在选来的位置上平移  如同以下例题:     

- (void)touchesBegan:(NSSet<UITouch *> *)toucheswithEvent:(UIEvent *)event

{

    CGAffineTransformtransform1 = view.transform;

    view.transform = CGAffineTransformScale(transform1, 0.90.9);

    view.transform = CGAffineTransformIdentity;   //动画还原

}

4.动画的产生

    [UIImageViewbeginAnimations:nilcontext:nil];    //注册开启动画

    [UIImageViewsetAnimationDuration:3]; //设置一次动画的持续时间

    [UIImageViewsetAnimationRepeatCount:1];//设置动画的循环次数

    CGAffineTransformtransform = view.transform;

    view.transform = CGAffineTransformRotate(transformM_PI_4);

    view.transform = CGAffineTransformTranslate(transform0, -300);

    [UIImageViewcommitAnimations];    //注册完成

原文地址:https://www.cnblogs.com/8023huihui/p/5200495.html