iOS开发Tips

作者: MrJ的杂货铺 | 来源:发表于2019-08-23 15:43 被阅读0次

    1.button按钮修改文字闪烁问题

    btn.titleLabel.text = @"111";//避免按钮闪动
    [btn setTitle:@"111" forState:UIControlStateNormal];
    

    2.TextView链接颜色修改问题

    self.privacyTextV.linkTextAttributes = @{NSForegroundColorAttributeName:Color(250, 175, 40)};
    

    3.自定义控件可在xib上使用

    - (void)awakeFromNib {
        [super awakeFromNib];
        //custom code
    }
    

    4.键盘删除事件

    //自定义TextField 重写deleteBackward方法
    - (void)deleteBackward
    {
        [super deleteBackward];
        //
    }
    

    5.enable和userInteraction的区别

    • enable对应UIControlStateDisabled状态
    • userInteraction 只对应交互性
      `

    6.connerstone add所有文件

    • 使用import
    • svn add * --force

    7.collectionView的Item的间距

    • minimumInteritemSpacing表示 同一个section内部间item的 和滚动方向垂直方向的间距;
    • minimumLineSpacing指的是同一个section 内部 item 的滚动方向的间距;

    8.cell分割线偏移

    if ([self.myTableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.myTableView setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 0)];
    }
    
    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        //  分割线去掉左边15个像素
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
    }
    

    9.imagePicker导航栏

    _imagePicker.navigationBar.tintColor = [UIColor whiteColor];
    _imagePicker.navigationBar.backgroundColor = [UIColor lt_hexStringToColor:@"#002A4C"];
    // 设置字体颜色
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [_imagePicker.navigationBar setTitleTextAttributes:attrs];
    

    10.Xcode不自动不全

    1.退出xcode
    2.删除deriveData文件夹( ~/Library/Developer/Xcode/DerivedData)
    3.删除com.apple.dt.Xcode文件(~/Library/Caches/com.apple.dt.Xcode)
    

    11.Library not loaded: /usr/lib/libstdc++.6

    真机:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.6.0.9.tbd
    模拟器:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libstdc++.6.0.9.dylib
    

    12.iOS 时间格式化

    G:      公元时代,例如AD公元
    yy:     年的后2位
    yyyy:   完整年
    MM:     月,显示为1-12,带前置0
    MMM:    月,显示为英文月份简写,如 Jan
    MMMM:   月,显示为英文月份全称,如 Janualy
    dd:     日,2位数表示,如02
    d:      日,1-2位显示,如2,无前置0
    EEE:    简写星期几,如Sun
    EEEE:   全写星期几,如Sunday
    aa:     上下午,AM/PM
    H:      时,24小时制,0-23
    HH:     时,24小时制,带前置0
    h:      时,12小时制,无前置0
    hh:     时,12小时制,带前置0
    m:      分,1-2位
    mm:     分,2位,带前置0
    s:      秒,1-2位
    ss:     秒,2位,带前置0
    S:      毫秒
    Z:      GMT(时区)
    

    iOS 13.collectionViewCell重写select

    override var isSelected: Bool {
        willSet {
            if newValue {
                    
            }else{
                    
            }
        }
    }
    

    14.xib动画

    self.inputViewBottomCon.constant = 40
    UIView.animate(withDuration: duration, animations: {
        self.view.layoutIfNeeded()
    })
    

    15.主线程刷新UI

    swift:
    DispatchQueue.main.async {
        //刷新UI
    }
    OC:
    dispatch_async(dispatch_get_main_queue(), ^{
       // UI更新代码
    });
    

    相关文章

      网友评论

        本文标题:iOS开发Tips

        本文链接:https://www.haomeiwen.com/subject/lbrtectx.html