您的位置:首页 > 移动开发 > IOS开发

iOS 11 中scrollview布局往下偏移问题automaticallyAdjustsScrollViewInsets、contentInsetAdjustmentBehavior(iOS 11

2018-01-09 18:20 393 查看
//
//  ViewController.m
//

#import "ViewController.h"
@interface ViewController ()
@property (nonatomic,strong)UIScrollView * scrollView;
@end

@implementation ViewController

- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.frame = CGRectMake(0, 0, 300, 300);
}
return _scrollView;
}

- (void)viewDidLoad {
self.scrollView.backgroundColor = [UIColor grayColor];
[self.view addSubview:self.scrollView];
//‼️=============判断系统版本
if (@available(iOS 11.0, *)) {
self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
NSLog(@"11.0f");
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
NSLog(@"10f");
}
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: