UIView的属性及方法
UIView的属性:
@property(nonatomic,readonly,copy) NSArray<__kindof UIView *> *subviews;
说明:subviews是一个数组,里面存放的元素都是UIView或者UIView的子类,数组元素的顺序是根据添加UIView或者UIView的子类先后顺序存取
@property(nullable, nonatomic,readonly) UIView *superview;
说明:可以通过superview这个属性拿到该视图的父视图
UIView的方法:
- (nullable __kindof UIView *)viewWithTag:(NSInteger)tag;
说明:这个方法可以通过该tag值获得该tag值下的控件,返回UIView类
例:UILabel *label = [[UILabe alloc] init];
label.tag = 10;
[self.view addSubview:label];
UIButton *button = [[UIButton alloc] init];
button.tag = 20;
[self.view addSubview:button];
UILabel *label2 = (UILabel *)[self.view viewWithTag:10];
UIView设置动画的一系列方法:
+ (void)beginAnimations:(nullable NSString *)animationID context:(nullable void *)context;
说明:表示将开始动画,即将展示的动画内容可以放在该方法后
+ (void)setAnimationDuration:(NSTimeInterval)duration;
说明:表示动画将延续多少秒+ (void)setAnimationDelay:(NSTimeInterval)delay;
说明:表示动画在多少秒后触发+ (void)commitAnimations;
说明:结束动画
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
说明:此方法可等价于上面方法