different of class and category

当需要重写父类中的方法时,这时候定义子类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@interface JADanSideController : JASidePanelController


@end


@implementation JADanSideController

- (UIBarButtonItem *)leftButtonForCenterPanel{

UIButton *leftBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
[leftBarButton setFrame:CGRectMake(0, 0, 44, 30)];
[leftBarButton setBackgroundImage:[UIImage imageNamed:@"List_NaviSide.png"] forState:UIControlStateNormal];
[leftBarButton addTarget:self action:@selector(toggleLeftPanel:) forControlEvents:UIControlEventTouchUpInside];
__autoreleasing UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBarButton];

return leftBarButtonItem;
}

@end

当需要为父类添加方法时,这时候定义类别

1
2
3
4
5
6
@interface JADanSideController : JASidePanelController

- (void)setBackGroundColor;

@end

作者

welsonla

发布于

2013-05-10

更新于

2020-01-01

许可协议

评论