最近公司新上項(xiàng)目盗冷,在制作全局的導(dǎo)航控制器視圖時用到了兩種方法:
1缆八、
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setBarTintColor:[UIColor fangBlueColor]];
2、
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"頂部欄.png"] stretchableImageWithLeftCapWidth:10 topCapHeight:10] forBarMetrics:UIBarMetricsDefault];
設(shè)置之后都可以達(dá)到滾動視圖是從導(dǎo)航欄下端開始的垃杖,但是出現(xiàn)了新的問題,在創(chuàng)建tableView的時候有兩種方法
1丈屹、
- (UITableView *)myTableView{
if (!_myTableView) {
_myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_myTableView.backgroundColor = [UIColor whiteColor];
_myTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_myTableView.delegate = self;
_myTableView.dataSource = self;
}
return _myTableView;
}
2调俘、
- (UITableView *)myTableView{
if (!_myTableView) {
_myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-64) style:UITableViewStylePlain];
_myTableView.backgroundColor = [UIColor whiteColor];
// _myTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_myTableView.delegate = self;
_myTableView.dataSource = self;
}
return _myTableView;
}
正常視圖
屏幕快照 2017-08-08 下午3.14.59.png
請注意上述兩種構(gòu)建視圖的方法,第一種若是讓視圖自適應(yīng)上下左右的間距旺垒,必須使視圖的frame為self.view.bounds彩库。第二種若是視圖的frame這么寫必須注釋掉autoresizingMask屬性的值,否則就會出現(xiàn)如下的視圖
有問題視圖
屏幕快照 2017-08-08 下午3.16.50.png
上述視圖底部的藍(lán)色是self.view的視圖先蒋,tableView沒能充滿視圖骇钦;
再此做個記錄!