UI學習第08天
最近一段時間自己的學習狀態真的很差,甚至到了一度想要放棄iOS學習的想法,因為一件事你長期堅持做了下去但是一直沒有達到你想要的效果,難免會感到沮喪或者是懈怠有時候真的很想放棄,但心裡又不甘心,自己投入了這麼多的精力去做的事兒,不能就此荒廢。這段時間各種事情在困擾著我,回家過年耽誤了半個月的時間,回來上班快一個月了這一個月的時間裡,每天都是一副要死不活的樣子,想法很多,但是依然只能坐在這方寸之地做著一些沒有意義,沒有營養,甚至是枯燥無味的生活。為了達到我元旦那天晚上立下的目標,我決心要改變現在的這個僵局,改變這種每天不溫不火的狀態,我一定要改變,而且要快。
2016年留給我的時間不多了,今天已經是3月9號了,馬上一年的四分之一就過去了。晚上躺在床上的時候我心裡在問自己,這個月過完你所立下的目標完成了四分之一嗎?難道還能只像學生時代那樣對自己的承諾只是當個屁在放?過了今年的五月份我就已經是年滿22週歲的青年了,早已不再是一個單純,幼稚,對未來充滿著意淫的糊塗蟲,古人說年滿二十即加冠,亦慕聖賢之道,霍去病在我這個年紀就已經是名滿天下的大司馬,被封侯拜相,供人敬仰了。我不求跟這種大氣魄,大毅力的人相比,只求能夠通過自己的勤奮,刻苦獲得自己想要的生活方式,實現自己的一些目標而已。但是如今以現在的狀態來看真的是所差甚遠,你真的要努力。
學習是一件長期不間斷堅持的事情,只有持之以恆才能有所收穫,看你學習的這九個月的時間裡,有很多時間都間斷了學習,三天打魚兩天曬這種做法百害而無一益,外人看你好似勤奮刻苦,可是真相只有你自己知道。
堅持,不斷堅持。
第08天學習筆記:
1、懶載入程式碼複習
model中封裝字典轉模型,載入plist檔案
+ (NSArray *)messagesList
{
//讀取plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"messages" ofType:@"plist"];
NSArray *dicArray = [NSArray arrayWithContentsOfFile:path];
//字典轉模型
NSMutableArray *tmpArray = [NSMutableArray array];
//上一條訊息
CZMessage *preMessage;
for (NSDictionary *dic in dicArray) {
CZMessage *message = [CZMessage messageWithDic:dic];
//獲取上一條訊息
// preMessage = [tmpArray lastObject];
if ([message.time isEqualToString:preMessage.time]) {
//時間相等 隱藏
message.hiddenTime = YES;
}
[tmpArray addObject:message];
//獲取上一條訊息
preMessage = message;
}
return tmpArray;
}
//1 懶載入
- (NSArray *)messageFrames
{
if (_messageFrames == nil) {
//1.1 載入模型資料
NSArray *messages = [CZMessage messagesList];
NSMutableArray *tmpArray = [NSMutableArray array];
//1.2 建立frame模型
for (CZMessage *msg in messages) {
CZMessageFrame *msgFrame = [[CZMessageFrame alloc] init];
msgFrame.message = msg;
[tmpArray addObject:msgFrame];
}
_messageFrames = tmpArray;
}
return _messageFrames;
}
//去掉分割線
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//不能選中
self.tableView.allowsSelection = NO;
//背景顏色
// self.tableView.backgroundColor = [UIColor lightGrayColor];
self.tableView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
//全0 黑色 全255 白色
// self.tableView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:0/255.0 alpha:1];
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
返回有幾行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
返回每一行的cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
4、tableView代理方法複習:
返回行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
返回footer的高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
5、重寫屬性的set方法時第一步一定時給屬性重新賦值:
- (void)setMessage:(CZMessage *)message
{
_message = message;
//獲取螢幕的寬度
UIScreen *screen = [UIScreen mainScreen];
CGFloat margin = 10;
//時間的frame
CGFloat timeW = screen.bounds.size.width;
CGFloat timeH = 40;
CGFloat timeX = 0;
CGFloat timeY = 0;
if (!message.isHiddenTime) {
_timeFrame = CGRectMake(timeX, timeY, timeW, timeH);
}
// 計算文字的大小
- (CGSize)sizeWithText:(NSString *)text maxSize:(CGSize)maxSize fontSize:(CGFloat)fontSize
{
return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil].size;
}
//設定訊息的背景圖片
if (msg.type == CZMessageTypeSelf) {
// [bgImage resizableImageWithCapInsets:<#(UIEdgeInsets)#>]
// [bgImage resizableImageWithCapInsets:<#(UIEdgeInsets)#> resizingMode:(UIImageResizingMode)]
[self.textView setBackgroundImage:[UIImage resizeImage:@"chat_send_nor"] forState:UIControlStateNormal];
[self.textView setBackgroundImage:[UIImage resizeImage:@"chat_send_press_pic"] forState:UIControlStateHighlighted];
}else{
[self.textView setBackgroundImage:[UIImage resizeImage:@"chat_recive_nor"] forState:UIControlStateNormal];
[self.textView setBackgroundImage:[UIImage resizeImage:@"chat_recive_press_pic"] forState:UIControlStateHighlighted];
}
//縮放圖片(平鋪)
- (UIImage *)resizeImage:(NSString *)imgName
{
UIImage *bgImage = [UIImage imageNamed:imgName];
//縮放圖片
bgImage = [bgImage stretchableImageWithLeftCapWidth:bgImage.size.width / 2 topCapHeight:bgImage.size.height / 2];
return bgImage;
}
相關文章
- UI學習第02天UI
- 第50天學習打卡(JavaScript)JavaScript
- Python學習第6天Python
- 第5天 學習弱讀
- FPGA 學習之路:verilog學習第5天FPGA
- 學習 Tipask-第 1 天 規劃思路
- HTML5學習筆記 - 第06天HTML筆記
- 學習UI設計需不需要天賦?UI
- 第108天:Ajax中XMLHttpRequest詳解XMLHTTP
- Linux(ubuntu)下30天自制os學習引導,第0天(1)LinuxUbuntu
- python學習筆記:第8天 檔案操作Python筆記
- Python學習筆記:第3天 字串的操作Python筆記字串
- iOS9 每日學習第4天:UIStack ViewiOSUIView
- 初學者。aspx學習日記第1天---faq (轉)
- 第08天OC語言(22):單例巨集抽取C語言單例
- python學習筆記:第4天 列表和元組Python筆記
- iOS9 每日學習第11天:GameplayKit 之 PathfindingiOSGAM
- 學車筆記(第1天)筆記
- 學車筆記(第2天)筆記
- 學車筆記(第3天)筆記
- 學車筆記(第4天)筆記
- 學習go的第7天遇到的一個小題分析Go
- MySQL 5.7 General Tablespace學習(r11筆記第34天)MySql筆記
- iOS9 每日學習第5天:Xcode Code Coverage ToolsiOSXCode
- iOS9 每日學習第12天:GameplayKit 之 Behaviors 和 GoalsiOSGAMGo
- semantic UI學習(二)UI
- python學習筆記:第10天 函式進階和作用域Python筆記函式
- 【Linux入門第1天】我為什麼要學習LinuxLinux
- 【學習圖片】08:WebPWeb
- 8086彙編學習
- Swift UI 學習資料SwiftUI
- Android UI元件學習AndroidUI元件
- 第 0 天/第 1 天/第 2 天:雲時代的軟體生命週期
- 前端週刊第62期:學習學習再學習前端
- Android UI學習 - Tab的學習和使用AndroidUI
- 近期的學習計劃(2017.3)(r11筆記第95天)筆記
- 我的CISA38天學習筆記(20080614考試)筆記
- Java學習第1章Java