zoukankan      html  css  js  c++  java
  • iOS 6 & iOS 7 的适配笔记

    iOS 6 & iOS 7 的适配

    场景1: 没有NavigationController,同时根视图是UIView
    - (void)viewWillLayoutSubviews

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
    NSLog(@"======> %f", [self.topLayoutGuide length]);
    CGFloat top = [self.topLayoutGuide length];

    // 直接修改self.view的bounds属性
    CGRect bounds = self.view.bounds;
    // 强行往下挤20个点,其它不变
    bounds.origin.y = -top;
    self.view.bounds = bounds;
    }

    可以抽成宏

    #define kIOS7_NONav_View

    - (void)viewWillLayoutSubviews

    {

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {

    NSLog(@"======> %f", [self.topLayoutGuide length]);

    CGFloat top = [self.topLayoutGuide length];

    CGRect bounds = self.view.bounds;

    bounds.origin.y = -top;

    self.view.bounds = bounds;

    }

    }

    场景2: 没有NavigationController,同时根视图是UIScrollView/UITableView
    - (void)viewDidLoad
    {
    [super viewDidLoad];

    // 根视图是一个UITableView,继承自UIScrollView
    // contentInset属性可以设置滚动视图距离边界的距离
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
    [self.tableView setContentInset:UIEdgeInsetsMake(20, 0, 0, 0)];
    }
    }

    场景3: 有NavigationController,同时根视图是UIView

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
    [self setEdgesForExtendedLayout:UIRectEdgeNone];
    }

    场景4: 有NavigationController,同时根视图是UIScrollView/UITableView

    不需要任何处理!

  • 相关阅读:
    在网页中实现截屏粘贴的功能
    CSS3 @font-face 做自定义图标
    Visual Studio报错一箩筐(持续更新)
    Axure实现vcg官网首页原型图
    Axure实现bootstrap首页线框图
    Web第一天——准备篇
    vue动态加载组件
    组件封装之将代码放到npm上
    node连接mysql生成接口,vue通过接口实现数据的增删改查(二)
    autoCAD2007 快捷键 标注
  • 原文地址:https://www.cnblogs.com/ChenYilong/p/3656748.html
Copyright © 2011-2022 走看看