UIButton文字和圖標間距:
[button setImageEdgeInsets:UIEdgeInsetsMake(0.0, -20, 0.0, 0.0)];
UITabbarItem的圖標大小改變:
vc.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
UISearchBar設(shè)置取消按鈕的文字:
[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]].title = @"取消";
自定義Tabbarcontroller:
- (void)setup {
self.tabBar.tintColor = [UIColor initWith:Color_Hex_Main];
self.tabBar.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0.96];
self.tabBar.translucent = NO;
[self addChildVC:[HomePageVC class] withTitle:@"首頁" withIconName:ImgName_home];
[self addChildVC:[CategoryPageVC class] withTitle:@"分類" withIconName:ImgName_sort];
[self addChildVC:[GrouppurchasePageVC class] withTitle:@"團購" withIconName:ImgName_Group_purchase];
[self addChildVC:[CartPageVC class] withTitle:@"購物車" withIconName:ImgName_shopping_cart];
[self addChildVC:[MinePageVC class] withTitle:@"我的" withIconName:ImgName_my];
}
- (void)addChildVC:(Class )str withTitle:(NSString *)title withIconName:(NSString *)iconName {
UIViewController *vc = [[str alloc]init];
BaseNavVC *nav = [[BaseNavVC alloc]initWithRootViewController:vc];
if ([title isEqualToString:@"團購"]) {
vc.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
}else{
vc.title = title;
}
vc.tabBarItem.image = [UIImage imageNamed:iconName];
vc.tabBarItem.image = [UIImage imageNamed:[iconName stringByAppendingString:@"_d"]];
nav.navigationBar.barTintColor = [UIColor initWith:Color_Hex_Main];
nav.navigationBar.backgroundColor = [UIColor initWith:Color_Hex_Main];
[self addChildViewController:nav];
}
UITabbarItem顯示圖標本身顏色:
vc.tabBarItem.image = [[UIImage imageNamed:iconName]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = [[UIImage imageNamed:[iconName stringByAppendingString:@"_d"]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITableViewCell僅僅更新視圖布局:
//僅僅更新視圖高度骚勘、這兩個方法會讓所有的cell重新布局痕钢,然后重新計算高度额嘿。
[tableView beginUpdates];
[tableView endUpdates];
UITableViewCell selectedBackgroundView修改位置:
重載:
- (void )layoutSubviews {
// always try to set frame in layoutSubviews
[super layoutSubviews];
//? ? CGRect frame = CGRectMake(52.0, 0, self.width-67.0, self.height);
CGRect frame = CGRectMake(self.contentView.originX+15.0, 0, self.contentView.width-30.0, self.height);
UIView *backView = [[UIView alloc] initWithFrame:frame];
[backView addCommonShadow:4.0];
[backView addLine: self.contentView.width-30.0 distance:38 isDistanceTop:NO];
self.selectedBackgroundView = backView;
self.selectedBackgroundView.backgroundColor = [UIColor whiteColor];
}
UITableViewCell ?選擇圖標修改:
- (void)layoutSubviews
{
[super layoutSubviews];
for (UIControl *control in self.subviews) {
if (![control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
continue;
}
[control mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self);
make.right.mas_offset(-30.0);
}];
for (UIView *subView in control.subviews) {
if (![subView isKindOfClass: [UIImageView class]]) {
continue;
}
UIImageView *imageView = (UIImageView *)subView;
if (self.selected) {
// KVC修改
//修改選中背景圖片等
} else {
//修改非選中背景圖片等
}}}
iOS 應(yīng)用跳轉(zhuǎn)到設(shè)置界面:
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
疑問:
GCC 有個visibility屬性, 該屬性是說, 啟用這個屬性:
1. 當-fvisibility=hidden時
動態(tài)庫中的函數(shù)默認是被隱藏的即 hidden. 除非顯示聲明為__attribute__((visibility("default"))).
2. 當-fvisibility=default時
動態(tài)庫中的函數(shù)默認是可見的.除非顯示聲明為__attribute__((visibility("hidden"))).
特別說明: 這個特性是 GCC4.0 以后才有的.
NSMutableArray便利構(gòu)造器
NSMutableArray?*marr=[NSMutableArrayarrayWithCapacity:5];
帶有capacity的方法,
其內(nèi)存原理如下:
capacity后的NSUInteger代表了開辟內(nèi)存的一個單位
初始在內(nèi)存中開辟5個內(nèi)存,如果之后數(shù)組元素多余5個,則會再開辟新的5*2個新的內(nèi)存,[考慮到數(shù)組的連續(xù)內(nèi)存的特性]
單位是以5,把之前的5個元素的內(nèi)容拷貝到新的十個新的內(nèi)存里面,把第六個
也放進去,然后釋放初始狀態(tài)創(chuàng)建的內(nèi)存5個
最后得到了一塊夠用的連續(xù)的內(nèi)存5*2
如果創(chuàng)建的framework中使用了category類,則在使用framework的項目配置中【Other Linker Flags】需要添加參數(shù)【-ObjC]或者【-all_load】呀枢。
如果使用framework的使用出現(xiàn)【Umbrella header for module 'XXXX' does not include header 'XXXXX.h'】,是因為錯把xxxxx.h拖到了public中。
如果出現(xiàn)【dyld: Library not loaded:XXXXXX】,是因為打包的framework版本太高筛严。比如打包framework時托修,選擇的是iOS 9.0忘巧,而實際的工程環(huán)境是iOS 8開始的。
指令集對應(yīng)的設(shè)備
armv6
iPhone睦刃、iPhone 3G
iPod 1G砚嘴、iPod 2G
armv7
iPhone 3GS、iPhone 4
iPod 3G涩拙、iPod 4G际长、iPod 5G
iPad、iPad 2兴泥、iPad 3工育、iPad Mini
armv7s
iPhone 5、iPhone 5C
iPad 4
arm64
iPhone 5s iPhone 6iPhone 6P iPhone 6s iPhone 6sP iPhone 7 iPhone 7P
iPad Air, Retina iPad Mini
判斷當前設(shè)備是否為iPhone X
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)