User Tools

Site Tools


Sidebar

Go Back

Refresh

You are not allowed to add pages

Direct Link

library:ios:tips

Coding Tips

1. Reading From info.plist

Swift

let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String

2. Button

2.1 Text Alignment

button.contentHorizontalAlignment = .right

3. 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];
}

4. 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}
        
        
library/ios/tips.txt · Last modified: 2024/03/06 17:11 by lhaosen