ios--随笔一

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);

说明:此方法可等价于上面方法







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值