xcode9 、 iOS 11适配

1. xcode9,在Images.xcassets中,AppIcon中需添加1024*1024的icon图片。
1.png
2. xcode9,在Images.xcassets中,LauchImage中需添加1125*2436的启动图,才能在iPhone X中正常显示。
2.png
3. UITableView为UITableViewStyleGrouped类型,可能会出现组section间距不对,需设置
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
3.png
4. 需要保存图片到相册时,iOS 11配置权限,Privacy - Photo Library Additions Usage Description
4.png
5. 在iOS 11中,设置导航栏titleView是UISearchBar时,样式会变化,导航栏高度会被撑高。可以用UIView把UISearchBar包起来。
    UIView *searchView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, 44)];
    self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 6, MainScreenWidth-67*MainScreenScale, 32)];
    self.searchBar.delegate = self;
    self.searchBar.placeholder = @"请输入国家名称";
    [searchView addSubview:self.searchBar];
    self.navigationItem.titleView = searchView;
继承UISearchBar,配置属性,保持iOS 11和iOS 10的样式一致
- (void)layoutSubviews
{
    [super layoutSubviews];
    if (IOS11_OR_LATER) {
        UIView *searchTextField = nil;
        searchTextField = [[[self.subviews firstObject] subviews] lastObject];
        if (searchTextField && [searchTextField isKindOfClass:[UITextField class]]) {
            UITextField *searchTF = (UITextField *)searchTextField;
            searchTF.frame = self.bounds;
            searchTF.font = [UIFont systemFontOfSize:13.5];
            if ([searchTF valueForKey:@"roundedRectBackgroundCornerRadius"]) {
                [searchTF setValue:@(4.5) forKey:@"roundedRectBackgroundCornerRadius"];
            }
        }
    }
}
5.1.png

5.2.png

你可能感兴趣的:(xcode9 、 iOS 11适配)