UINavgationController 的返回按鈕被自定義之后枪狂,系統(tǒng)的左滑pop功能就會(huì)失效场躯。
解決:在控制器里加上這行代碼
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
UIButton
給按鈕設(shè)置了image和title結(jié)果發(fā)現(xiàn),image太大?文字位置不理想?
就像這樣
before.png
試試設(shè)置按鈕的imageEdgeInsets和contentEdgeInsets兩個(gè)屬性吧。請(qǐng)看
after.png
想要設(shè)置按鈕的文字左對(duì)齊蠢挡?
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
導(dǎo)航控制器popViewController時(shí),導(dǎo)航欄閃黑凳忙?
請(qǐng)調(diào)用: [self.navigationController setNavigationBarHidden:0 animated:1];
如果你在點(diǎn)擊tabBar時(shí)业踏,發(fā)現(xiàn)標(biāo)簽的順序鬼使神差的迷之錯(cuò)位了,那請(qǐng)檢查是不是在哪個(gè)控制器里面把self.title設(shè)置為空了涧卵。
想要隱藏tableView的header嗎試試下面的方法吧
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight = 160;
if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
} else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
AutoLayout狀態(tài)下勤家,執(zhí)行完viewDidLoad、viewWillAppear等方法后柳恐,還會(huì)執(zhí)行viewDidLayoutSubviews方法, 在這個(gè)方法中伐脖,我們可以重新對(duì)某個(gè)子View,甚至某個(gè)ChildViewController的View進(jìn)行Frame調(diào)整
UILabel
設(shè)置字體加粗:setFont:[UIFont fontWithName:@"Helvetica-Bold" size:11]
改變 Helvetica-Bold 以設(shè)置不同的字體
想要在同一個(gè)label中顯示不同顏色的文字嗎乐设?
NSString *ori_str = [NSString stringWithFormat:@"您評(píng)論了%@的作品",self.user2The.nick];
NSRange range = [ori_str rangeOfString:self.user2The.nick]; NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:ori_str];
[attribute addAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]} range:range];
[self.systemInfoLabel setText:ori_str];
[self.systemInfoLabel setAttributedText:attribute];
百度地圖
如果調(diào)用api 程序卡死讼庇,請(qǐng)檢查是否 【BMKMapManager start 】
如果打開(kāi)地圖發(fā)現(xiàn)滿滿的網(wǎng)格,那一定是appkey 與 bundle id 不對(duì)應(yīng)近尚。
改變導(dǎo)航欄字體顏色蠕啄。
直接設(shè)置 navigationBar
setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}
App Store 地址拼接規(guī)則
https://itunes.apple.com/gb/app/yi-dong-cai-bian/id(apple ID)?mt=8
長(zhǎng)按UITextField彈出的pop為英文
解決方法:修改Info.plist中的Localization native development region為China
UITextField 站位文字顏色
兩種方法
// 1.attributedPlaceholder
// _username.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用戶名" attributes:@{NSForegroundColorAttributeName: color1}];
// 2.KVC
// [_username setValue:color1 forKeyPath:@"_placeholderLabel.textColor"];
限制UITextField 輸入位數(shù)
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
if (textField == self.inpt) {
if (string.length == 0) return YES;
NSInteger existedLength = textField.text.length;
NSInteger selectedLength = range.length;
NSInteger replaceLength = string.length;
if (existedLength - selectedLength + replaceLength > 3) {
return NO;
}
}
return YES;
}
應(yīng)用內(nèi)可隨時(shí)切換語(yǔ)言時(shí),MJRefresh下拉文字的處理
NSBundle+MJRefresh.m
// NSString *language = [NSLocale preferredLanguages].firstObject;// 框架源代碼
NSString *language = [[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"];
并且注掉 if (bundle == nil)