一、纯代码自定义等高cell


首先创建一个继承UITableViewCell的类
@interface XMGTgCell : UITableViewCell
在该类中依次做一下操作
1.添加子控件

  1. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  2. {
  3. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  4. // 图片
  5. UIImageView *iconImageView = [[UIImageView alloc] init];
  6. [self.contentView addSubview:iconImageView];
  7. self.iconImageView = iconImageView;
  8.  
  9. // 标题
  10. UILabel *titleLabel = [[UILabel alloc] init];
  11. [self.contentView addSubview:titleLabel];
  12. self.titleLabel = titleLabel;
  13.  
  14. // 价格
  15. UILabel *priceLabel = [[UILabel alloc] init];
  16. [self.contentView addSubview:priceLabel];
  17. self.priceLabel = priceLabel;
  18.  
  19. // 购买数
  20. UILabel *buyCountLabel = [[UILabel alloc] init];
  21. [self.contentView addSubview:buyCountLabel];
  22. self.buyCountLabel = buyCountLabel;
  23. }
  24. return self;
  25. }

创建子控件

2.布局子控件

/**

* 需要注意的是通过initWithStyle:创建cell,就不会调用下面这个方法
* - (instancetype)initWithFrame:(CGRect)frame;
* 那么可以在layoutSubviews中计算所有子控件的frame

* 需求:图片与lable之间,lable与屏幕的margin都是10(加配图)
*/

  1. - (void)layoutSubviews
  2. {
  3. [super layoutSubviews];
  4.  
  5. CGFloat margin = ;
  6. CGFloat contentH = self.contentView.frame.size.height;
  7. CGFloat contentW = self.contentView.frame.size.width;
  8.  
  9. // 图片
  10. CGFloat iconX = margin;
  11. CGFloat iconY = margin;
  12. CGFloat iconW = ;
  13. CGFloat iconH = contentH - * iconY;
  14. self.iconImageView.frame = CGRectMake(iconX, iconY, iconW, iconH);
  15.  
  16. // 标题
  17. CGFloat titleX = iconX + iconW + margin;
  18. CGFloat titleY = iconY;
  19. CGFloat titleW = contentW - titleX - margin;
  20. CGFloat titleH = ;
  21. self.titleLabel.frame = CGRectMake(titleX, titleY, titleW, titleH);
  22.  
  23. // 价格
  24. CGFloat priceX = titleX;
  25. CGFloat priceH = ;
  26. CGFloat priceY = iconY + iconH - priceH;
  27. CGFloat priceW = ;
  28. self.priceLabel.frame = CGRectMake(priceX, priceY, priceW, priceH);
  29.  
  30. // 购买数
  31. CGFloat buyCountW = ;
  32. CGFloat buyCountH = ;
  33. CGFloat buyCountX = contentW - margin - buyCountW;
  34. CGFloat buyCountY = iconY + iconH - buyCountH;
  35. self.buyCountLabel.frame = CGRectMake(buyCountX, buyCountY, buyCountW, buyCountH);
  36. }

布局子控件

3.设置子控件数据
在设置数据之前,我们可以创建一个TG类,用于保存每一个cell的数据,这就是典型的数据转模型,在前面也有介绍过,比如我们的数据是这样的

实现代码:

  1. /******************* XMGTg.h *******************/
  2. #import <Foundation/Foundation.h>
  3.  
  4. @interface XMGTg : NSObject
  5. /** 标题 */
  6. @property (nonatomic, copy) NSString *title;
  7. /** 购买数 */
  8. @property (nonatomic, copy) NSString *buyCount;
  9. /** 图片 */
  10. @property (nonatomic, copy) NSString *icon;
  11. /** 价格 */
  12. @property (nonatomic, copy) NSString *price;
  13.  
  14. + (instancetype)tgWithDict:(NSDictionary *)dict;
  15. @end
  16.  
  17. /******************* XMGTg.m *******************/
  18. #import "XMGTg.h"
  19.  
  20. @implementation XMGTg
  21. + (instancetype)tgWithDict:(NSDictionary *)dict
  22. {
  23. XMGTg *tg = [[self alloc] init];
  24. [tg setValuesForKeysWithDictionary:dict];
  25. return tg;
  26. }
  27. @end
  28.  
  29. /******************* XMGTgCell *******************/
  30. #import <UIKit/UIKit.h>
  31. @class XMGTg;
  32.  
  33. @interface XMGTgCell : UITableViewCell
  34. /** 团购模型数据 */
  35. @property (nonatomic, strong) XMGTg *tg;
  36. @end
  37.  
  38. // 那么重写tg的setter方法就可以设置数据了
  39. - (void)setTg:(XMGTg *)tg
  40. {
  41. _tg = tg;
  42.  
  43. self.iconImageView.image = [UIImage imageNamed:tg.icon];
  44. self.titleLabel.text = tg.title;
  45. self.priceLabel.text = [NSString stringWithFormat:@"¥%@", tg.price];
  46. self.buyCountLabel.text = [NSString stringWithFormat:@"%@人已购买", tg.buyCount];
  47. }

设置子控件数据

二、Autolayout布局子控件(Masonry)


在布局控件时我们可以使用三方框架,Masonry
那么我么可以直接把创建子控件以及布局控件全部写在
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
这个方法中

  1. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  2. {
  3. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  4. CGFloat margin = ;
  5.  
  6. // 图片
  7. UIImageView *iconImageView = [[UIImageView alloc] init];
  8. [self.contentView addSubview:iconImageView];
  9. self.iconImageView = iconImageView;
  10.  
  11. [iconImageView makeConstraints:^(MASConstraintMaker *make) {
  12. make.left.top.equalTo(self.contentView).offset(margin);
  13. make.bottom.equalTo(self.contentView).offset(-margin);
  14. make.width.equalTo();
  15. }];
  16.  
  17. // 标题
  18. UILabel *titleLabel = [[UILabel alloc] init];
  19. [self.contentView addSubview:titleLabel];
  20. self.titleLabel = titleLabel;
  21.  
  22. [titleLabel makeConstraints:^(MASConstraintMaker *make) {
  23. make.top.equalTo(iconImageView);
  24. make.left.equalTo(iconImageView.right).offset(margin);
  25. make.height.equalTo();
  26. make.right.equalTo(self.contentView).offset(-margin);
  27. }];
  28.  
  29. // 价格
  30. UILabel *priceLabel = [[UILabel alloc] init];
  31. priceLabel.font = [UIFont systemFontOfSize:];
  32. priceLabel.textColor = [UIColor orangeColor];
  33. [self.contentView addSubview:priceLabel];
  34. self.priceLabel = priceLabel;
  35.  
  36. [priceLabel makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.equalTo(titleLabel);
  38. make.bottom.equalTo(iconImageView);
  39. make.size.equalTo(CGSizeMake(, ));
  40. }];
  41.  
  42. // 购买数
  43. UILabel *buyCountLabel = [[UILabel alloc] init];
  44. buyCountLabel.font = [UIFont systemFontOfSize:];
  45. buyCountLabel.textColor = [UIColor grayColor];
  46. buyCountLabel.textAlignment = NSTextAlignmentRight;
  47. [self.contentView addSubview:buyCountLabel];
  48. self.buyCountLabel = buyCountLabel;
  49.  
  50. [buyCountLabel makeConstraints:^(MASConstraintMaker *make) {
  51. make.bottom.equalTo(iconImageView);
  52. make.right.equalTo(titleLabel);
  53. make.size.equalTo(CGSizeMake(, ));
  54. }];
  55. }
  56. return self;
  57. }

使用三方框架布局子控件

三、字典转模型的几种方式(MJExtension)


1.遍历数组
一般最笨的方法分以下三步:加载字典数组、创建模型数组、将字典数组转换为模型数组
示例代码如下:

  1. - (NSArray *)tgs
  2. {
  3. if (!_tgs) {
  4. // 加载字典数组
  5. NSArray *dictArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tgs" ofType:@"plist"]];
  6.  
  7. // 创建模型数组
  8. NSMutableArray *tgArray = [NSMutableArray array];
  9.  
  10. // 将字典数组 -> 模型数组
  11. for (NSDictionary *dict in dictArray) {
  12. XMGTg *tg = [XMGTg tgWithDict:dict];
  13. [tgArray addObject:tg];
  14. }
  15. _tgs = tgArray;
  16. }
  17. return _tgs;
  18. }

2.世界流行框架MJExtension
再来看看用李明杰的MJExtension框架怎么解决
有一个方法,一句话可以解决

  1. _tgs = [XMGTg objectArrayWithFilename:@"tgs.plist"];

或者这样

  1. _tgs = [XMGTg objectArrayWithFile:[[NSBundle mainBundle] pathForResource:@"tgs" ofType:@"plist"]];

或是这样

  1. _tgs = [XMGTg objectArrayWithKeyValuesArray:[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tgs" ofType:@"plist"]]];

那么在上次说到的索引条案例中可以这样写

  1. // 懒加载
  2. - (NSArray *)cargroups
  3. {
  4. if (!_cargroups) {
  5. // 提前告诉CarGroup类其中的Cars数组要解析成什么模型数组
  6. [CarGroup setupObjectClassInArray:^NSDictionary *{
  7. return @{
  8. @"cars": @"Car"
  9. };
  10. }];
  11. _cargroups = [CarGroup objectArrayWithFilename:@"cars.plist"];
  12.  
  13. }
  14. return _cargroups;
  15. }

四、xib自定义等高的cell


首先可以先创建一个名为XMGTgCell继承UITableViewCell的类
然后创建你想要的xib文件


并且xib中的Custom Class中的class一定要设置成XMGTgCell
最后在XMGTgCell的实现中重写

- (void)setTg:(XMGTg *)tg
设置数据

  1. #import <UIKit/UIKit.h>
  2.  
  3. @class XMGTg;
  4.  
  5. @interface XMGTgCell : UITableViewCell
  6. /** 团购模型数据 */
  7. @property (nonatomic, strong) XMGTg *tg;
  8. @end
  9.  
  10. #import "XMGTgCell.h"
  11. #import "XMGTg.h"
  12.  
  13. @interface XMGTgCell()
  14. @property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
  15. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *priceLabel;
  17. @property (weak, nonatomic) IBOutlet UILabel *buyCountLabel;
  18. @end
  19.  
  20. @implementation XMGTgCell
  21.  
  22. - (void)setTg:(XMGTg *)tg
  23. {
  24. _tg = tg;
  25.  
  26. self.iconImageView.image = [UIImage imageNamed:tg.icon];
  27. self.titleLabel.text = tg.title;
  28. self.priceLabel.text = [NSString stringWithFormat:@"¥%@", tg.price];
  29. self.buyCountLabel.text = [NSString stringWithFormat:@"%@人已购买", tg.buyCount];
  30. }
  31. @end

五、不同类型的cell共存


首先在cellForRowAtIndexPath方法中返回不同类型的cell

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3. if (indexPath.row % == ) {
  4. XMGTgCell *cell = [tableView dequeueReusableCellWithIdentifier:tgID];
  5. cell.tg = self.tgs[indexPath.row];
  6. return cell;
  7. } else {
  8. XMGNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:newsID];
  9. return cell;
  10. }
  11. }

并且在使用这些cell之前要先注册

  1. - (void)viewDidLoad {
  2. [super viewDidLoad];
  3.  
  4. self.tableView.rowHeight = ;
  5.  
  6. [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([XMGTgCell class]) bundle:nil] forCellReuseIdentifier:tgID];
  7. [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([XMGNewsCell class]) bundle:nil] forCellReuseIdentifier:newsID];
  8. }

效果如下

六、storyboard自定义cell


这两种不同的cell绑定的Identifier分别为:tg、test
那么让我们来看下代码

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3. if (indexPath.row % == ) {
  4. static NSString *ID = @"tg";
  5. XMGTgCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  6.  
  7. cell.tg = self.tgs[indexPath.row];
  8.  
  9. return cell;
  10. } else {
  11. return [tableView dequeueReusableCellWithIdentifier:@"test"];
  12. }
  13. }

如果我们在viewDidLoad注册一个Identifier为tg,并且类型为UITableViewCell的cell,会出现什么情况呢

  1. - (void)viewDidLoad {
  2. [super viewDidLoad];
  3.  
  4. [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"tg"];
  5. }

经过测试,发现运行程序会直接蹦了,并且报了一个错误
reason: '-[UITableViewCell setTg:]: unrecognized selector sent to instance 0x7f8fcbc2be70'

这里是什么意思呢,首先在这里要知道 "当缓存池中找不到cell 的时候,先根据重用标识从注册这里找,然后再从storysboard中找"
这个错误的意思是发送了一个不能识别的消息-[UITableViewCell setTg:]
也就是说UITableViewCell中的setTg方法它找不到,程序运行到
"cell.tg = self.tgs[indexPath.row];这一句时就会报错,因为我们根本没有在UITableViewCell里创建tg这个属性,自然也就找不到tg的set方法,进而可以验证上面所说的系统会优先选择代码创建的cell而不是storyboard里的"

七、分割线,静态cell


分割线的原理:实际上cell中的Content View的高度要比cell少1左右的高度(大概),那么我们可以紧贴着Content View底部添加一个高度为0~1、宽度等于cell的view,并把颜色设置为灰色,最好将self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;不显示分割线

静态cell,iPhone的设置界面就是用的静态cell

八、团购案例(TG)

最后是今天自己敲的完整的代码

团购案例

  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface ViewController : UITableViewController
  4.  
  5. @end
  6.  
  7. #import "ViewController.h"
  8. #import "TgCellTableViewCell.h"
  9. #import "MJExtension.h"
  10. #import "TgCell.h"
  11.  
  12. #define ID @"chgCell"
  13.  
  14. @interface ViewController ()
  15. @property (nonatomic, strong) NSArray *tgCells;
  16. @end
  17.  
  18. @implementation ViewController
  19. - (NSArray *)tgCells
  20. {
  21. if (nil == _tgCells) {
  22. _tgCells = [TgCell objectArrayWithFilename:@"tgs.plist"];
  23. }
  24. return _tgCells;
  25. }
  26.  
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.tableView.rowHeight = ;
  30.  
  31. // self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  32.  
  33. [self.tableView registerClass:[TgCellTableViewCell class] forCellReuseIdentifier:ID];
  34.  
  35. }
  36.  
  37. - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  38. {
  39. return self.tgCells.count;
  40. }
  41.  
  42. - (UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  43. {
  44. TgCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  45. cell.tgcell = self.tgCells[indexPath.row];
  46.  
  47. return cell;
  48. }
  49. @end
  50.  
  51. /**************** TgCellTableViewCell*******************/
  52. #import <UIKit/UIKit.h>
  53. #import "TgCell.h"
  54. @interface TgCellTableViewCell : UITableViewCell
  55. @property (nonatomic, strong) TgCell *tgcell;
  56. @end
  57.  
  58. #import "TgCellTableViewCell.h"
  59.  
  60. @interface TgCellTableViewCell()
  61. // 图标
  62. @property (nonatomic, weak) UIImageView *icon_imageView;
  63. // 标题
  64. @property (nonatomic, weak) UILabel *titel_lable;
  65. // 价格
  66. @property (nonatomic, weak) UILabel *price_lable;
  67. // 购买人数
  68. @property (nonatomic, weak) UILabel *buy_lable;
  69.  
  70. @end
  71.  
  72. @implementation TgCellTableViewCell
  73.  
  74. // 添加一个灰色的边框
  75. - (void)awakeFromNib
  76. {
  77. self.layer.borderWidth = ;
  78. self.layer.borderColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.3].CGColor;
  79. }
  80.  
  81. // 添加所有子控件
  82. - (nonnull instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
  83. {
  84. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  85. // 1.创建图标
  86. UIImageView *icon_imageView = [[UIImageView alloc] init];
  87. [self.contentView addSubview:icon_imageView];
  88. self.icon_imageView = icon_imageView;
  89.  
  90. // 2.创建标题
  91. UILabel *titel_lable = [[UILabel alloc] init];
  92. [self.contentView addSubview:titel_lable];
  93. self.titel_lable = titel_lable;
  94.  
  95. // 3.创建价格
  96. UILabel *price_lable = [[UILabel alloc] init];
  97. [self.contentView addSubview:price_lable];
  98. price_lable.textColor = [UIColor orangeColor];
  99. price_lable.font = [UIFont systemFontOfSize:];
  100. self.price_lable = price_lable;
  101.  
  102. // 4.创建购买人数
  103. UILabel *buy_lable = [[UILabel alloc] init];
  104. [self.contentView addSubview:buy_lable];
  105. buy_lable.textAlignment = NSTextAlignmentRight;
  106. buy_lable.textColor = [UIColor grayColor];
  107. buy_lable.font = [UIFont systemFontOfSize:];
  108. self.buy_lable = buy_lable;
  109.  
  110. }
  111. return self;
  112. }
  113.  
  114. // 布局控件
  115. - (void)layoutSubviews
  116. {
  117. [super layoutSubviews];
  118.  
  119. CGFloat margin = ;
  120. CGFloat contentW = self.contentView.frame.size.width;
  121. CGFloat contentH = self.contentView.frame.size.height;
  122. // 设置frame
  123. // 1、设置图标的frame
  124. CGFloat icon_imageViewX = margin;
  125. CGFloat icon_imageViewY = margin;
  126. CGFloat icon_imageViewW = ;
  127. CGFloat icon_imageViewH = contentH - * margin;
  128. self.icon_imageView.frame = CGRectMake(icon_imageViewX, icon_imageViewY, icon_imageViewW, icon_imageViewH);
  129.  
  130. // 2、设置标题的frame
  131. CGFloat titel_lableX = CGRectGetMaxX(self.icon_imageView.frame) + margin;
  132. CGFloat titel_lableY = margin;
  133. CGFloat titel_lableW = contentW - titel_lableX - margin;
  134. CGFloat titel_lableH = ;
  135. self.titel_lable.frame = CGRectMake(titel_lableX, titel_lableY, titel_lableW, titel_lableH);
  136.  
  137. // 3、设置价格的frame
  138. CGFloat price_lableX = titel_lableX;
  139. CGFloat price_lableH = ;
  140. CGFloat price_lableW = ;
  141. CGFloat price_lableY = CGRectGetMaxY(self.icon_imageView.frame) - price_lableH;
  142. self.price_lable.frame = CGRectMake(price_lableX, price_lableY, price_lableW, price_lableH);
  143.  
  144. // 4、设置购买人数的frame
  145. CGFloat buy_lableX = CGRectGetMaxX(self.price_lable.frame) + margin;
  146. CGFloat buy_lableH = ;
  147. CGFloat buy_lableY = CGRectGetMaxY(self.icon_imageView.frame) - buy_lableH;
  148. CGFloat buy_lableW = contentW - buy_lableX - margin;
  149. self.buy_lable.frame = CGRectMake(buy_lableX, buy_lableY, buy_lableW, buy_lableH);
  150.  
  151. }
  152.  
  153. - (void)setTgcell:(TgCell *)tgcell
  154. {
  155. _tgcell = tgcell;
  156.  
  157. self.icon_imageView.image = [UIImage imageNamed:tgcell.icon];
  158. self.titel_lable.text = tgcell.title;
  159. self.price_lable.text = [NSString stringWithFormat:@"¥%@",tgcell.price];
  160. self.buy_lable.text = [NSString stringWithFormat:@"%@人购买",tgcell.buyCount];
  161. }
  162.  
  163. @end
  164.  
  165. /**************** TgCell*******************/
  166. #import <Foundation/Foundation.h>
  167.  
  168. @interface TgCell : NSObject
  169. /** 标题 */
  170. @property (nonatomic, copy) NSString *title;
  171. /** 购买数 */
  172. @property (nonatomic, copy) NSString *buyCount;
  173. /** 图片 */
  174. @property (nonatomic, copy) NSString *icon;
  175. /** 价格 */
  176. @property (nonatomic, copy) NSString *price;
  177. @end
  178.  
  179. #import "TgCell.h"
  180.  
  181. @implementation TgCell
  182.  
  183. @end

iOS开发——UI进阶篇(二)自定义等高cell,xib自定义等高的cell,Autolayout布局子控件,团购案例的更多相关文章

  1. iOS开发——UI进阶篇(三)自定义不等高cell,如何拿到cell的行高,自动计算cell高度,(有配图,无配图)微博案例

    一.纯代码自定义不等高cell 废话不多说,直接来看下面这个例子先来看下微博的最终效果 首先创建一个继承UITableViewController的控制器@interface ViewControll ...

  2. iOS开发——UI进阶篇(十)导航控制器、微博详情页、控制器的View的生命周期

    一.导航控制器出栈 1.initWithRootViewController本质 UIViewController *vc = [[OneViewController alloc] init]; // ...

  3. iOS开发——UI进阶篇(十二)事件处理,触摸事件,UITouch,UIEvent,响应者链条,手势识别

    触摸事件 在用户使用app过程中,会产生各种各样的事件 一.iOS中的事件可以分为3大类型 触摸事件加速计事件远程控制事件 响应者对象在iOS中不是任何对象都能处理事件,只有继承了UIResponde ...

  4. iOS开发——UI进阶篇(十八)核心动画小例子,转盘(裁剪图片、自定义按钮、旋转)图片折叠、音量震动条、倒影、粒子效果

    一.转盘(裁剪图片.自定义按钮.旋转) 1.裁剪图片 将一张大图片裁剪为多张 // CGImageCreateWithImageInRect:用来裁剪图片 // image:需要裁剪的图片 // re ...

  5. iOS开发——UI进阶篇(四)tableView的全局刷新,局部刷新,左滑操作,左滑出现更多按钮,进入编辑模式,批量删除,自定义批量删除

    首先创建项目,在storyboard如下布局控件,设置好约束 然后创建cell模型类XMGWineCell数据模型类XMGWine创建UITableView,设置数据源协议,实现数据源方法懒加载数据这 ...

  6. iOS开发——UI进阶篇(十五)Quartz2D介绍

    一.Quartz2D简介 1.什么是Quartz2DQuartz 2D是一个二维绘图引擎,同时支持iOS和Mac系统 Quartz 2D能完成的工作绘制图形 : 线条\三角形\矩形\圆\弧等绘制文字绘 ...

  7. iOS开发——UI进阶篇(七)程序启动原理、打电话、发短信

    一.Info.plist常见的设置 1.建立一个工程后,会在Supporting files文件夹下看到一个“工程名-Info.plist”的文件,该文件对工程做一些运行期的配置,非常重要,不能删除 ...

  8. iOS开发——UI进阶篇(十七)CALayer,核心动画基本使用

    一.CALayer简介 1.CALayer在iOS中,文本输入框.一个图标等等,这些都是UIView你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个其实UIView之所以 ...

  9. iOS开发——UI进阶篇(十六)Quartz2D实战小例子

    一.画线 只有在drawRect中才能获取到跟view相关联的上下文 - (void)drawRect:(CGRect)rect {} 一条线 // 1.获取跟当前View相关联的layer上下文(画 ...

随机推荐

  1. Cheminformatic Set

    蛋白: 数据库 1. 蛋白晶体结构数据库 http://www.rcsb.org/pdb/home/home.do 2. 蛋白注释数据库 http://www.uniprot.org/ 工具 1. r ...

  2. SSM的各个配置文件

    SqlMapConfig.xml文件:(这是带了mybatis的分页插件的配置) <?xml version="1.0" encoding="UTF-8" ...

  3. 【原】gulp快速入门

    今天刚入职了一家新公司,结果明天就要开始项目了.上级说要用gulp来打包代码,所以今晚花了一晚来看这个gulp, 可以说已经入门了.所以做一个小小的总结 : 首先全局安装gulp npm instal ...

  4. JavaWeb学习笔记——DAO设计模式

  5. CMAKE使用

    http://www.cppblog.com/tx7do/archive/2010/08/19/124000.html http://blog.csdn.net/dbzhang800/article/ ...

  6. VIM的姿势

    http://blog.csdn.net/vincent_czz/article/details/7900670 http://bbs.feng.com/read-htm-tid-7435912.ht ...

  7. JSONModel 嵌套字典数组 JSONModel nest NSDictionary NSArray

    JSONModel 嵌套字典数组  JSONModel nest NSDictionary NSArray

  8. MBProgressHUD+FastCall

    + (void)showHudTipStr:(NSString *)tipStr; + (void)showHudTipStr:(NSString *)tipStr{ ) { MBProgressHU ...

  9. php Hash Table(二) Hash函数

    哈希表最关键的几个方面有: 通过key访问(通过哈希函数计算出key) 映射到数据结构中(哈希表本身的存储结构) 映射的处理(冲突或者碰撞检测和处理函数) 理解PHP的哈希算法 一般来说对于整形索引进 ...

  10. Python Web Crawler

    Python版本:3.5.2 pycharm URL Parsing¶ https://docs.python.org/3.5/library/urllib.parse.html?highlight= ...