開(kāi)發(fā)中遇到了以前用過(guò)的知道的知識(shí)點(diǎn)郁岩,就懶得再去寫了婿奔,要么從之前的項(xiàng)目中找缺狠,要么去谷歌百度再去篩選,這樣很影響開(kāi)發(fā)效率萍摊。所以挤茄,好記性不如爛筆頭,把常用的知識(shí)點(diǎn)匯總了一下冰木,下次需要時(shí)驮樊,直接打開(kāi)項(xiàng)目筆記,全局搜索片酝,幾秒搞定囚衔。gitHub下載地址:https://github.com/leeSmile/iOSknowledgeGather
.h文件知識(shí)點(diǎn)目錄
/*
1.NSString過(guò)濾特殊字符
2.TransForm屬性
3.計(jì)算方法耗時(shí)時(shí)間間隔
4.Alert提示宏定義
5.讓iOS應(yīng)用直接退出
6.快速求總和 最大值 最小值 和 平均值
7.修改Label中不同文字顏色
8.Label行間距
9.UIImageView填充模式
10.iOS 開(kāi)發(fā)中一些相關(guān)的路徑
11.關(guān)于隱藏navigationbar
12.自動(dòng)處理鍵盤事件,實(shí)現(xiàn)輸入框防遮擋的插件
13.設(shè)置字體和行間距
14.點(diǎn)擊button倒計(jì)時(shí)
15.修改textFieldplaceholder字體顏色和大小
16.圖片拉伸
17.去掉導(dǎo)航欄下邊的黑線
18.修改pagecontrol顏色
19.去掉UITableView的section的粘性雕沿,使其不會(huì)懸停
20.UIImage與字符串互轉(zhuǎn)
21.判斷NSString中是否包含中文
22.NSDate與NSString的相互轉(zhuǎn)化
23.控件的局部圓角
24.navigationBar的透明問(wèn)題
25.全局設(shè)置navigationBar標(biāo)題的樣式和barItem的標(biāo)題樣式
26.側(cè)滑手勢(shì)返回
27.給webView添加頭視圖
28.模態(tài)跳轉(zhuǎn)的動(dòng)畫設(shè)置
29.圖片處理只拿到圖片的一部分
30.給UIView設(shè)置圖片
31.給TableView或者CollectionView的cell添加簡(jiǎn)單動(dòng)畫
32.線程中更新 UILabel的text
33.獲得當(dāng)前硬盤空間
34.ActivityViewController 使用AirDrop分享
35.保存全屏為image
36.獲取通訊錄聯(lián)系人的電話號(hào)碼
37.用WebView加載頁(yè)面练湿,提前獲取頁(yè)面的高度
*/
.m文件部分知識(shí)點(diǎn)實(shí)現(xiàn)
#pragma 37.用WebView加載頁(yè)面,提前獲取頁(yè)面的高度
可以獲得內(nèi)容高度审轮,但是網(wǎng)絡(luò)不好時(shí)肥哎,不準(zhǔn)確
1.webView.scrollView.contentSize.height;
獲取的高度較為準(zhǔn)確
2.[[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] intValue]
#pragma 36.獲取通訊錄聯(lián)系人的電話號(hào)碼
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
ABPeoplePickerNavigationControllerDelegate
- (void)addAddress
{
RYLog(@"選擇聯(lián)系人");
ABPeoplePickerNavigationController * vc = [[ABPeoplePickerNavigationController alloc] init];
vc.peoplePickerDelegate = self;
[self presentViewController:vc animated:YES completion:nil];
}
#pragma mark -- ABPeoplePickerNavigationControllerDelegate
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef valuesRef = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFIndex index = ABMultiValueGetIndexForIdentifier(valuesRef,identifier);
//電話號(hào)碼
CFStringRef telValue = ABMultiValueCopyValueAtIndex(valuesRef,index);
[self dismissViewControllerAnimated:YES completion:^{
self.addressV.telnum.text = (__bridge NSString *)telValue;
}];
}
#pragma 35.保存全屏為image
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
for (UIWindow * window in [[UIApplication sharedApplication] windows]) {
if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) {
CGContextSaveGState(context);
CGContextTranslateCTM(context, [window center].x, [window center].y);
CGContextConcatCTM(context, [window transform]);
CGContextTranslateCTM(context, -[window bounds].size.width*[[window layer] anchorPoint].x, -[window bounds].size.height*[[window layer] anchorPoint].y);
[[window layer] renderInContext:context];
CGContextRestoreGState(context);
}
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
#pragma 34.ActivityViewController 使用AirDrop分享
使用AirDrop 進(jìn)行分享:
NSArray *array = @[@"test1", @"test2"];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:array applicationActivities:nil];
[self presentViewController:activityVC animated:YES
completion:^{
NSLog(@"Air");
}];
#pragma 33.獲得當(dāng)前硬盤空間
NSFileManager *fm = [NSFileManager defaultManager];
NSDictionary *fattributes = [fm attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
NSLog(@"容量%lldG",[[fattributes objectForKey:NSFileSystemSize] longLongValue]/1000000000);
NSLog(@"可用%lldG",[[fattributes objectForKey:NSFileSystemFreeSize] longLongValue]/1000000000);
這是部分知識(shí)點(diǎn)的實(shí)現(xiàn),完整的請(qǐng)?jiān)趃ithub上下載疾渣,歡迎star篡诽。