美文网首页
十一论剑之iOS项目实战(二)

十一论剑之iOS项目实战(二)

作者: 阿拉斯加的狗 | 来源:发表于2016-09-27 18:06 被阅读32次

    控制台可能会输出以下警告信息

    • 警告的原因: [UIImage imageNamed:nil]
    CUICatalog: Invalid asset name supplied: (null)
    CUICatalog: Invalid asset name supplied: (null)
    
    • 警告的原因: [UIImage imageNamed:@""]
    CUICatalog: Invalid asset name supplied:
    CUICatalog: Invalid asset name supplied:
    

    准确判断一个字符串是否有内容

    if (string.length) {
    
    }
    
    /*
    错误写法:
    if (string) {
    
    }
    */
    

    替换UITabBarController内部的tabBar

    // 这里的self是UITabBarController
    [self setValue:[[WKTabBar alloc] init] forKeyPath:@"tabBar"];
    

    center和size的设置顺序

    • 建议的设置顺序
      • 先设置size
      • 再设置center

    给系统自带的类增加分类

    • 建议增加的分类属性名\方法名前面加上前缀, 比如
    @interface UIView (XMGExtension)
    @property (nonatomic, assign) CGFloat wk_width;
    @property (nonatomic, assign) CGFloat wk_height;
    @property (nonatomic, assign) CGFloat wk_x;
    @property (nonatomic, assign) CGFloat wk_y;
    @property (nonatomic, assign) CGFloat wk_centerX;
    @property (nonatomic, assign) CGFloat wk_centerY;
    
    @property (nonatomic, assign) CGFloat wk_right;
    @property (nonatomic, assign) CGFloat wk_bottom;
    @end
    

    按钮常见的访问方法

    [button imageForState:UIControlStateNormal].size;
    button.currentImage.size;
    
    [button backgroundImageForState:UIControlStateNormal];
    button.currentBackgroundImage;
    
    [button titleForState:UIControlStateNormal];
    button.currentTitle;
    
    [button titleColorForState:UIControlStateNormal];
    button.currentTitleColor;
    

    设置按钮的内边距

    @property(nonatomic) UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR;
    @property(nonatomic) UIEdgeInsets titleEdgeInsets;
    @property(nonatomic) UIEdgeInsets imageEdgeInsets;
    

    解决导航控制器pop手势失效

    self.interactivePopGestureRecognizer.delegate = self;
    
    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
    {
        // 手势何时有效 : 当导航控制器的子控制器个数 > 1就有效
        return self.childViewControllers.count > 1;
    }
    

    相关文章

      网友评论

          本文标题:十一论剑之iOS项目实战(二)

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