在开发中最重要的就是屏幕适配问题了,Masonry是最常用的第三方库了。在最近开发中,小编遇到了件很奇怪的问题,在这里记录下。
先简单说下问题吧:小编的导航栏和标签栏用的是系统自带的,大家都知道用了系统自带的导航栏和标签栏可能会导致坐标出现一些问题,一般都会设置self.navigationController.navigationBar.translucent = NO;
self.tabBarController.tabBar.translucent = NO;
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.view addSubview:self.tableView];
这样一看是没有问题,可是一调试会发现tableView底部总会有一部分内容被标签栏所遮住,即使设了self.tabBarController.tabBar.translucent = NO;也没有用。
最后改成这样就可以了
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.bottom.equalTo(self.view);
}];
frame: 该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统)
bounds:该view在本地坐标系统中的位置和大小。(参照点是,本地坐标系统,就相当于ViewB自己的坐标系统,以0,0点为起点)
导航栏透明度能影响bounds坐标,标签栏不能。如果用Masonry就都能影响