====== Coding Tips ======
===== - Reading From info.plist =====
==== Swift ====
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
===== - Button =====
==== - Text Alignment ====
button.contentHorizontalAlignment = .right
===== - ASFTableView在高版本ios(16+)的显示bug =====
- (void)initialize {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
[_tableView setDataSource:self];
[_tableView setDelegate:self];
[_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[_tableView setBackgroundColor:[UIColor clearColor]];
if (@available(iOS 15.0, *)) {
_tableView.sectionHeaderTopPadding = 0;
}
[self addSubview:_tableView];
}
===== - APP屏幕居中 =====
在ViewController中 viewDidLoad()添加偏移
let screenWidth = UIScreen.main.bounds.size.width
let uiWidth = 84.5 * 12
var uiOffsetX = (screenWidth - uiWidth) / 2
if(uiOffsetX<0.0) {uiOffsetX = 0.0}