一、修改控件的位置

1、上下左右的移动改变可以用frame 注意 frame的值不能直接修改需要设置一个临时变量

//change position

CGRect oldFrame = self.imageview.frame;

oldFrame.origin.y+=10;

//set animation

[UIView animateWithDuration:3 animations:^{

self.imageview.frame = oldFrame;

}];

//change size

CGRect oldFrame = self.imageview.frame;

oldFrame.size.width+=10;

[UIView animationWithDuration:3 ,animations:^{

self.imageview.frame= oldFrame;

}];

2、使用transform既可以改变位置、尺寸、也可以进行旋转 M_PI /M_PI_2/M_PI_4分别代表 一个PI 1/2个PI和1/4p

   // First using transform to totating 

  self.imageview.transform = CGAffineTransformRotate(self.imageview.transform,M_PI);

     //Also :CGAffineTransformMakeRotation(M_PI) but when rotating ,it will not continue rotating

  //CGAffineTransformMakeScale(CGFloat sx,CGFloat sy);// Change Size CGAffineTransformMakrTranslation(CGFloat tx,CGFloat ty) change   Position

二、UIView控件属性补充

1、如何创建label并让它随机生成在某个view中

UILabel *label = [[UILabel alloc]init]; //init

label.text =[ NSString stringWithFormat:@"label"];//set title

label.textColor =[UIColor blackColor];//set color

label.frame = CGRectMake(arc4random_uniform(200),arc4random_uniform(200),10,10);

label.backgroundColor = [UIColor whiteColor];

[self.view addSubview:label]; 

注意:如果是UIView类型的话,可直接初始化设置frame initWithFrame(CGRect);

 

2、如何清空view里面指定控件

[label removeFromSuperview];

removeFromSuperView

三、图片浏览器

1、如何禁用按钮(enabeld)

self.btn.enabled = YES;

2、图片浏览实现动画的步骤

   1)把需要的图片添加进数组

  UIImage *image = [UIImage imageNamed:@"father"];

  NSMutableArray *arry =[NSMutableArray array];

  [arry addObject:image]

 

   2)把包含图片对象的数组赋值给Imageview.animationImages

  self.imageview.animationImages = arry;

  

  3)设置细节(次数默认无限,间隔)

  self.imageview.animationDuration = ?;self.imageview.animationRepeatCount=?;

  

  4)开始动画

  [self.imageview startAnimating];/[self.imageview stopAnimating]/isAnimating;

3、内存处理

图片播放的两种方式: 通过图片名获取imageName/通过图片路径获取

优劣势:

imageName:图片会自动缓存,导致内存飙升,内存释放:程序崩溃,或者当开发者看到内存警告时进行清理

imageWithContentsOfFile :图片不会缓存,需要获取路径 NSBundle(类似应用程序的安装包)图片如果放在assets里,打包后是无法提取的

相当于苹果公司自动给内部进行压缩和加密了。内存加载完就会释放

//set path:

NSBundle *mainBundle = [NSBundle mainBundle];

NSString *path = [mainBundle pathForResource:@"images" ofType: @"plist"];

NSArray *arry =[NSArray arrayWithContensOfFile:path];

NSDirctionary *dict = arry[0];

self.label.text = @"dict[@"desc"]";

self.label2.text = @"dict[@"name"]";

4、程序的启动原理

  1、Main中的main方法

  2、UIApplicationmain

  3、找到Main中设置好的xx。storyboard

  4、找到创建箭头所指的控制器 isinitalViewController

  5、创建storyboard中所有文本值,创建对应的控制

  6、当storyboard读取完毕以后,调用viewDidLoad

  7、呈现给用户

storyboard的本质

  storyboard的本质就是一个有一定格式的文本文件  这种是使用xml编写的文件,通过标签的形式标示信息 ;storyboadr上的拖拽会自动对xml文件进行修改

5、查看沙盒路径

NSLog(NSHomeDirectory);

Finder- 前往