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 ];
// 开始动画
[ UIView beginAnimations : @"hehehe" context : NULL ];
//设置动画的属性
//设置动画持续的时间 setAnimationDuration
[
UIView
setAnimationDuration
:
2
];
// 设置动画的代理 setAnimationDelegate
[ UIView setAnimationDelegate : self ];
// 设置动画的代理 setAnimationDelegate
[ UIView setAnimationDelegate : self ];
//设置动画的加速方式 setAnimationCurve
[
UIView
setAnimationCurve
:
UIViewAnimationCurveEaseInOut
];
//设置动画的重复次数 setAnimationRepeatCount
[
UIView
setAnimationRepeatCount
:
2
];
// 设置动画是否反方向执行 setAnimationRepeatAutoreverses
[ UIView setAnimationRepeatAutoreverses : YES ];
// 延迟调用动画 setAnimationDelay
// 设置动画是否反方向执行 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 );
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 ;
}];
}];
[ 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
{
- ( 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);
- ( void )animationDidStop:( NSString *)animationID finished:( NSNumber *)finished context:( void *)context
{
NSLog ( @"animationID is %@" , animationID);
}