UI第三天

来源:互联网 发布:单片机1602显示器程序 编辑:程序博客网 时间:2024/06/06 02:30

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


注意:

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

    imageV.animationImages = photoArray ;

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

    imageV.animationRepeatCount =3 ;

一定要开启动画

    [imageVstartAnimating] ;


一些概念:

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

   它们的共同点都是结构体

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

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

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

    

2. 什么是定时器?

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

   第一个参数 间隔的时间

   第二个参数 目标对象

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

   第四个参数 携带的参数

   第五个参数 是否重复调用

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

(1)暂停定时器

        [timersetFireDate:[NSDatedistantFuture]];

(2)重启定时器

       timer.fireDate = [NSDatedistantPast];


3.UIImageView用于显示图片

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

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


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

imageView.userInteractionEnabled = YES;


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

    imageView.layer.masksToBounds = YES;

    imageView.clipsToBounds = YES;


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

[self.viewsendSubviewToBack:greenLabel];

将绿色标签提到最上层:

[self.viewbringSubviewToFront:greenLabel];

交换两个层级:

[self.viewexchangeSubviewAtIndex:0withSubviewAtIndex:2];


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

第一种方式:

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

    [UIView beginAnimations:nil context:nil];

    设置动画的播放时间

    [UIViewsetAnimationDuration:2.0];

    设置动画的重复次数

    [UIViewsetAnimationRepeatCount:2.0];

    设置动画延迟播放的时间

    [UIViewsetAnimationDelay:2.0];

   提交动画

    [UIViewcommitAnimations];

    

第二种方式:

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

    [UIView animateWithDuration:2.0 animations:^{

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

        backView.backgroundColor = [UIColor redColor];

    }] ;


    [UIViewanimateWithDuration:2.0animations:^{

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

        backView.backgroundColor = [UIColorredColor];

    }completion:^(BOOL finished) {

       NSLog(@"已结束");

    }] ;



0 0
原创粉丝点击