| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- //
- // XJTopMenu.m
- // XJAVPlayer
- //
- // Created by xj_love on 2016/10/27.
- // Copyright © 2016年 Xander. All rights reserved.
- //
- #import "XJTopMenu.h"
- #import "UIView+SCYCategory.h"
- @interface XJTopMenu ()
- @property (nonatomic, strong)UIButton *backButton;
- @property (nonatomic, strong)UILabel *titleLabel;
- @end
- @implementation XJTopMenu
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- [self addAllView];
- }
- return self;
- }
- - (void)addAllView{
-
- [self addSubview:self.backButton];
- [self addSubview:self.titleLabel];
- }
- #pragma mark - **************************** 控件事件 *************************************
- - (void)goBack{
- if (self.xjTopGoBack) {
- self.xjTopGoBack();
- }
- }
- #pragma mark - **************************** 懒加载 *************************************
- - (UIButton *)backButton{
- if (_backButton == nil) {
- _backButton = [[UIButton alloc] init];
- [_backButton setBackgroundImage:[UIImage imageNamed:@"go_back"] forState:UIControlStateNormal];
- [_backButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
- }
- return _backButton;
- }
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.font = [UIFont systemFontOfSize:18];
- _titleLabel.textColor = [UIColor whiteColor];
- }
- return _titleLabel;
- }
- - (void)setXjAvTitle:(NSString *)xjAvTitle{
- _xjAvTitle = xjAvTitle;
- _titleLabel.text = _xjAvTitle;
- }
- #pragma mark - **************************** 布局 *************************************
- - (void)layoutSubviews{
- [super layoutSubviews];
-
- if (self.xjHidenBackBtn) {
- self.backButton = nil;
- }else{
- self.backButton.frame = CGRectMake(5, 8, 24, 24);
- }
- if (self.xjHidenBackBtn) {
- self.titleLabel.frame = CGRectMake(5, 5 , 200, 30);
- }else{
- self.titleLabel.frame = CGRectMake(45, 5 , 200, 30);
- }
-
-
- }
- @end
|