我不知道的cateGory

2015-12-10  本文已影响0人  瞅你咋地

什么是cateGory?

  • cateGory是一种类别

[Category相关链接] (http://cocoacats.com/)


  • (1)无法向类别中(interface)添加新的实体变量
* (2)名称冲突 (类别方法与原始方法冲突时,类别方法优先,将完全取代初始方法,而无法在使用初始方法)

  • (1)可以将类的实现分散到不同的文件当中

接下来我列举一下我们项目中用到的cateGory 。

#import "UIImageView+AFNetworking.h"(使用cateGory加载图片)
[cell.image setImageWithURL:[NSURL URLWithString:dic[@"logoPath"]]];

 [cell.image setImageWithURL:[NSURL URLWithString:dic[@"logoPath"]]];```

* 校验是否为有效的手机号 ``#import "NSString+MALNSString.h"
``

(![_TextFieldThree.text isMobilePhoneNumber])


* 设置导航栏背景图片 ,和Title ``#import "UIViewController+MALNavigation.h"
``

[UIViewController setNavigationBarBgImage:self.navigationController andBgImage:[UIImage imageNamed:@"图片名字"]];
[self setCenterItemWithTitle:@""];


* 设置btn的点事件``#import "UIViewController+MALNavigation.h"
``

[barItem.contentBarItem addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];


* 创建Category``@interface UIImageView_Bg : UIImageView
``
把_删除在Bg处用()括住 把继承删除
上一篇 下一篇

猜你喜欢

热点阅读