iOS UI初级-UIVew与UIWindow

1.UIKit是一个提供了在iOS上实现图形,事件驱动程序的框架
主要类别
①UIView是视图的基类
②UIViewController视图控制器的基类
③UIResponder表示一个可以接受触摸屏上的触摸事件的对象
ios不要设置多个window
2.UIWindow的创建

①UIScreen对象可以充当iOS设备物理屏幕的替代者
②UIWindow有三个优先级
UIWindowLevelAltert  优先级最高
UIWindowLevelNormal 优先级最低,默认

clearColor透明色
3.UIView的创建与使用
①视图:在iphone上看到的控件大部分都是UIview子类
②通常是UIview的一个对象,表示屏幕上的一块矩形区域
③一个视图也可以作为其他视图的子视图,同时决定着这些视图的位置和大小
MVC是框架模式,不是设计模式
Frame和Bounds
Frame是以父视图为起点,得出自己的位置信息
扩展:修改view的bounds,一般都不去修改它,自己的横纵坐标不会改变,但是会改变子视图的坐标
创建的两种方式

修改frame两种方法
创建视图



insertSubview:如果插入的视图已经存在视图数组中,则只是交换视图的下标位置,如果不存在视图数组中,则把视图添加到数组中,并持有这块空间。
通过标示找到数组
4.坐标系统变换
CGAffineTransformScale 对视图比例缩放
CGAffineTransformTranslate对视图原来的位置做平移
CGAffineTranformRotate 对试图做变焦旋转
UIview对象支持动画的属性有以下几个:
UIView属性动画-代理设置
动画属性参数
    UIView *view = [ self . window viewWithTag : 2015 ];
   
   
// 开始动画
    [
UIView beginAnimations : @"hehehe" context : NULL ];
   
    //设置动画的属性
    //设置动画持续的时间 setAnimationDuration
    [ UIView setAnimationDuration : 2 ];
   
   
// 设置动画的代理 setAnimationDelegate
    [
UIView setAnimationDelegate : self ];
   
    //设置动画的加速方式 setAnimationCurve
    [ UIView setAnimationCurve : UIViewAnimationCurveEaseInOut ];
   
    //设置动画的重复次数 setAnimationRepeatCount
    [ UIView setAnimationRepeatCount : 2 ];
   
   
// 设置动画是否反方向执行 setAnimationRepeatAutoreverses
    [
UIView setAnimationRepeatAutoreverses : YES ];
   
//    延迟调用动画 setAnimationDelay
    [UIView setAnimationDelay:2];

//    动画值的修改
    view.
alpha = 0 ;
//
//    改变 frame
   
CGRect frame = view. frame ;
    frame.
origin . y = 350 ;
    view.
frame = frame;
//
//    改变背景颜色
    view.
backgroundColor = [ UIColor redColor ];
   
   
// 改变 transform
    view.
transform = CGAffineTransformRotate (view. transform , M_PI / 4 );
   
    //提交动画 commitAnimations
    [UIView commitAnimations];

//block 动画
    [
UIView animateWithDuration : 2
                    
animations :^{
                         view.
transform = CGAffineTransformRotate (view. transform , M_PI / 4 );
                     }];
   
    [
UIView animateWithDuration : 2
                    
animations :^{
                         view.
transform = CGAffineTransformRotate (view. transform , M_PI / 4 );
                     }
                    
completion :^( BOOL finished) {
                         [
UIView animateWithDuration : 2
                                         
animations :^{
                                              view.
transform = CGAffineTransformIdentity ;
                                          }];
                     }];

// 动画将要开始的时候调用的方法
- (
void )animationWillStart:( NSString *)animationID context:( void *)context
{
    NSLog(@"animationID is %@", animationID);
}

// 动画已经结束的时候调用的方法
- (
void )animationDidStop:( NSString *)animationID finished:( NSNumber *)finished context:( void *)context
{
   
NSLog ( @"animationID is %@" , animationID);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值