學(xué)習(xí)小資料

1.cocoaPods報錯 : [!] Unable to add a source with url https://github.com/CocoaPods/Specs.git named master-1.

You can try adding it manually in ~/.cocoapods/repos or via pod repo add.

解決方法:這是因為電腦里安裝了另外一個Xcode導(dǎo)致cocoapods找不到路徑了

在終端執(zhí)行 sudo xcode-select -switch /Applications/Xcode.app 即可

2.安裝cocoapods的時候出現(xiàn) ERROR: While executing gem ... (Errno::EPERM)

Operation not permitted - /usr/bin/pod

解決辦法:直接在終端執(zhí)行 sudo gem install -n /usr/local/bin cocoapods

3.在狀態(tài)欄增加網(wǎng)絡(luò)請求的菊花,類似safari加載網(wǎng)頁的時候狀態(tài)欄菊花

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

4.檢查一個rect是否包含一個point

// point是否在rect內(nèi)

BOOL isContains = CGRectContainsPoint(rect, point);

5.在指定的寬度下,讓UILabel自動設(shè)置最佳font

label.adjustsFontSizeToFitWidth = YES;

6.將一個image保存在相冊中

UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

或者

#import

[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{

PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];

changeRequest.creationDate? ? ? ? ? = [NSDate date];

} completionHandler:^(BOOL success, NSError *error) {

if (success) {

NSLog(@"successfully saved");

}

else {

NSLog(@"error saving to photos: %@", error);

}

}];

7.修改cell.imageView的大小

UIImage *icon = [UIImage imageNamed:@""];

CGSize itemSize = CGSizeMake(30, 30);

UIGraphicsBeginImageContextWithOptions(itemSize, NO ,0.0);

CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);

[icon drawInRect:imageRect];

cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

8.為一個view添加虛線邊框

CAShapeLayer *border = [CAShapeLayer layer];

border.strokeColor = [UIColor colorWithRed:67/255.0f green:37/255.0f blue:83/255.0f alpha:1].CGColor;

border.fillColor = nil;

border.lineDashPattern = @[@4, @2];

border.path = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;

border.frame = view.bounds;

[view.layer addSublayer:border];

9.UITextView中打開或禁用復(fù)制,剪切,選擇,全選等功能

// 繼承UITextView重寫這個方法

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender

{

// 返回NO為禁用,YES為開啟

// 粘貼

if (action == @selector(paste:)) return NO;

// 剪切

if (action == @selector(cut:)) return NO;

// 復(fù)制

if (action == @selector(copy:)) return NO;

// 選擇

if (action == @selector(select:)) return NO;

// 選中全部

if (action == @selector(selectAll:)) return NO;

// 刪除

if (action == @selector(delete:)) return NO;

// 分享

if (action == @selector(share)) return NO;

return [super canPerformAction:action withSender:sender];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容