剛開始看到這樣的代碼時候,第一個瞬間是有點將其代碼對齊的衝動,好吧,也許是有點強迫症。ide
- // start the slide up animation
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:0.3];
- // we need to perform some post operations after the animation is complete
- [UIView setAnimationDelegate:self];
- self.pickerView.frame = pickerRect;
- // shrink the table vertical size to make room for the date picker
- CGRect newFrame = self.tableView.frame;
- newFrame.size.height -= self.pickerView.frame.size.height;
- self.tableView.frame = newFrame;
- [UIView commitAnimations];
但是在同一頁面上,又看到了這樣的一處相似的代碼。post
我才瞬間意思到什麼。由於這些代碼是官方的實例代碼。學習
良好的代碼書寫格式除了命名以外,必要的格式縮進,可以良好的表達一段功能邏輯代碼的開始和結束。spa
在書寫代碼的時候,除了if,for語句等的縮進,這種獨立功能的寫法,委實是比較好的方式,值得好好體會學習。orm