控制台可能会输出以下警告信息
- 警告的原因: [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:[[XMGTabBar alloc] init] forKeyPath:@"tabBar"];
center和size的设置顺序
给系统自带的类增加分类
@interface UIView (XMGExtension)
@property (nonatomic, assign) CGFloat xmg_width;
@property (nonatomic, assign) CGFloat xmg_height;
@property (nonatomic, assign) CGFloat xmg_x;
@property (nonatomic, assign) CGFloat xmg_y;
@property (nonatomic, assign) CGFloat xmg_centerX;
@property (nonatomic, assign) CGFloat xmg_centerY;
@property (nonatomic, assign) CGFloat xmg_right;
@property (nonatomic, assign) CGFloat xmg_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;
}
网友评论