UI第三天

imageView Label的用户交互默认是关闭的


注意:

图片数组中必须存放的是UIImage的对象

    imageV.animationImages = photoArray ;

当重复次数设置为0时,会无限循环

    imageV.animationRepeatCount = 3 ;

一定要开启动画

    [imageV startAnimating] ;


一些概念:

1.frame bounds center之间的联系与区别:

   它们的共同点都是结构体

   frameCGRect:它描述的是子视图在父视图中的位置和大小

   boundsCGRect:它描述的是视图在自身坐标系中的位置和大小(0,0)

   centerCGPoint:它描述的是子视图在父视图中的位置

    

2. 什么是定时器?

   它是NSTimer的对象,它的作用是间隔某一段时间调用某一个方法

   第一个参数 间隔的时间

   第二个参数 目标对象

   第三个参数 方法(注意如果方法携带参数,那么这个参数就是NSTimer对象)

   第四个参数 携带的参数

   第五个参数 是否重复调用

 NSTime *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(XXXX:) userInfo:@"提百万" repeats:YES];

(1)暂停定时器

        [timer setFireDate:[NSDate distantFuture]];

(2)重启定时器

        timer.fireDate = [NSDate distantPast];


3.UIImageView用于显示图片

 UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 40, 200, 300)];

 imageView.image = [UIImage imageNamed:@"angry_00.jpg"];


4.如果要在imageView上添加按钮,必须保证用户交互是打开的

imageView.userInteractionEnabled = YES;


5.强制剪切  减掉超出父视图的部分

    imageView.layer.masksToBounds = YES;

    imageView.clipsToBounds = YES;


6.将将绿色标签置于最底层:

[self.view sendSubviewToBack:greenLabel];

将绿色标签提到最上层:

[self.view bringSubviewToFront:greenLabel];

交换两个层级:

[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];


7.UIView动画,它是通过改变控件的位置和大小以及颜色来实现的

第一种方式:

    告诉系统要准备开始播放动画

    [UIView beginAnimations:nil context:nil];

    设置动画的播放时间

    [UIView setAnimationDuration:2.0];

    设置动画的重复次数

    [UIView setAnimationRepeatCount:2.0];

    设置动画延迟播放的时间

    [UIView setAnimationDelay:2.0];

    提交动画

    [UIView commitAnimations];

    

第二种方式:

    第一个参数是动画播放时间

    [UIView animateWithDuration:2.0 animations:^{

        backView.frame = CGRectMake(300, 300, 100, 100);

        backView.backgroundColor = [UIColor redColor];

    }] ;


    [UIView animateWithDuration:2.0 animations:^{

        backView.frame = CGRectMake(300, 300, 100, 100);

        backView.backgroundColor = [UIColor redColor];

    } completion:^(BOOL finished) {

        NSLog(@"已结束");

    }] ;



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值