一、去掉tableviewcell
的左邊多余的15像素
- 1.可以改變
tableviewcell
的樣式為
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
然后在自定義的cell下面加上一個(gè)UIview
在底部,設(shè)置UIview
的顏色為分割線的樣式即可 - 2.同樣設(shè)置
tableviewcell
的樣式為
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
在自定義的cell中重寫下面這個(gè)方法,然后設(shè)置self.tableView.backgroundColor = CommonBgColor;
這樣就分割線的顏色就會(huì)顯示為和tableview的背景顏色一致了
/**
* 重寫這個(gè)方法的目的: 能夠攔截所有設(shè)置cell frame的操作
*/
- (void)setFrame:(CGRect)frame
{
// 這里可以自定義cell分割線的樣式
CGFloat margin= 1;
frame.size.height -= margin;
frame.origin.y += margin;
[super setFrame:frame];
}
- 3.首先在viewDidLoad方法加入以下代碼:
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
然后在重寫willDisplayCell方法
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
即可實(shí)現(xiàn)分割線的長度 = 屏幕的寬度
二、調(diào)節(jié)Label的行間距
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.contentLabel.text];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:3];
//調(diào)整行間距
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.contentLabel.text length])];
self.contentLabel.attributedText = attributedString;
三克婶、iOS 開發(fā)中一些相關(guān)的路徑
- 1.模擬器的位置:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
- 2.文檔安裝位置:
/Applications/Xcode.app/Contents/Developer/Documentation/DocSets
- 3.插件保存路徑:
~/Library/ApplicationSupport/Developer/Shared/Xcode/Plug-ins
- 4.自定義代碼段的保存路徑:(如果找不到CodeSnippets文件夾沮尿,可以自己新建一個(gè)CodeSnippets文件夾)
~/Library/Developer/Xcode/UserData/CodeSnippets/
- 5.證書路徑
~/Library/MobileDevice/Provisioning Profiles
四稠鼻、獲取 iOS 路徑的方法
- 獲取家目錄路徑的函數(shù)
NSString *homeDir = NSHomeDirectory();
- 獲取Documents目錄路徑的方法
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
- 獲取tmp目錄路徑的方法
NSString *tmpDir = NSTemporaryDirectory();
五商佑、字符串相關(guān)操作
- 去除所有的空格
[str stringByReplacingOccurrencesOfString:@" " withString:@""]
- 去除首尾的空格
[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
- 全部字符轉(zhuǎn)為大寫字母
- (NSString *)uppercaseString;
- 全部字符轉(zhuǎn)為小寫字母
- (NSString *)lowercaseString
六耕挨、NULL – nil – Nil – NSNULL的區(qū)別
- nil是OC的舷礼,空對(duì)象鹃彻,地址指向空(0)的對(duì)象。對(duì)象的字面零值
- Nil是Objective-C類的字面零值
- NULL是C的妻献,空地址蛛株,地址的數(shù)值是0团赁,是個(gè)長整數(shù)
- NSNull用于解決向NSArray和NSDictionary等集合中添加空值的問題