屏幕适配AutoResizing

作者: 挖掘机 | 来源:发表于2016-02-19 18:09 被阅读157次

适配器简介

AutoResizing

屏幕适配的历史

-iPhonestyGS\IPhone4

-没有屏幕适配可言

-全部用frame,bounds,center进行布局

-很多重要的现象:坐标值,宽度,高度全度写死


以前的屏幕适配
objc
UIButton *btn=[][UIButton alloc]init];
btn.frame=CGRectMake(0,0,320-b,480-b);



-iPad,iPhone横屏

-Autoresizing

-横竖屏幕适配相对简单


-让子控件可以跟随父控件行为自动发生相应的变化


-前提关闭auto layout


-局限性

  -只能解决子控件和父控件的相对关系
  
  -不能解决兄弟控件的相互关系
@interface ViewController ()

/**  父控件  */
@property(nonatomic,strong)UIView * blueView ;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    UIView *blueView=[[UIView alloc]init];
    blueView.backgroundColor=[UIColor blueColor];
    blueView.frame=CGRectMake(0, 0, 250, 250);
    [self.view  addSubview:blueView];
    self.blueView=blueView;
    
    
    UIView *redView=[[UIView alloc]init];
    redView.backgroundColor=[UIColor redColor];
    redView.frame=CGRectMake(0, 150, 250, 100);
    redView.autoresizingMask=
    UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleWidth  ;
    [blueView addSubview:redView];
    /**
     enum {
     UIViewAutoresizingNone                 = 0,
     UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
     UIViewAutoresizingFlexibleWidth        = 1 << 1,
     UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
     UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
     UIViewAutoresizingFlexibleHeight       = 1 << 4,
     UIViewAutoresizingFlexibleBottomMargin = 1 << 5
     };
     */
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
    
    
    
    
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    
    CGFloat h=200+arc4random_uniform(100);
    CGFloat w=200+arc4random_uniform(100);
    
    self.blueView.frame=CGRectMake(0, 0, w, h);
}

@end



相关文章

  • 屏幕适配AutoResizing

    适配器简介 AutoResizing 屏幕适配的历史 -iPhonestyGS\IPhone4 -没有屏幕适配可言...

  • she

    1.适配的分类 系统适配 屏幕适配 1.1屏幕适配历史 1.1.1autoresizing 去掉auto layo...

  • iOS-屏幕适配实现(Autoresizing)

    Autoresizing简介 Autoresizing是苹果早期屏幕适配的解决办法,当时iOS设备机型很少、屏幕尺...

  • iOS开发 屏幕适配(Autoresizing)

    Autoresizing简介 Autoresizing是苹果早期屏幕适配的解决办法,当时iOS设备机型很少、屏幕尺...

  • 关于iOS屏幕适配小结

    屏幕适配 屏幕适配的四种方式 frame和bounds Autoresizing AutoLayout 和 mas...

  • 屏幕适配的总结笔记

    一、屏幕适配-autoresizing简单使用 1、为什么要屏幕适配? > iphone手机屏幕尺寸呈现多样化。 ...

  • Autoresizing与AutoLayout

    Autoresizing Autoresizing是在AutoLayout流行以前的一种屏幕适配技术,Autore...

  • 屏幕适配

    Autoresizing 在Autolayout之前,有Autoresizing可以作屏幕适配,但局限性较大,有些...

  • 横竖屏代码适配

    屏幕适配跑不脱以下几种方法,这就一一道来: Autoresizing; Autoresizing是Autolayo...

  • Autoresizing

    一丶 Autoresizing 1.1 摘要: 苹果在iOS2中引入了Autoresizing技术用于屏幕适配,...

网友评论

    本文标题:屏幕适配AutoResizing

    本文链接:https://www.haomeiwen.com/subject/hrlvkttx.html