Commit 2c58cbb641ca1f947cae1df9f39cfece90e406d3
1 parent
6a71c966
no message
Showing
3 changed files
with
90 additions
and
23 deletions
CNLiveScioLive/Pages/Base/CNLiveENTabBarController.m
| ... | ... | @@ -9,7 +9,9 @@ |
| 9 | 9 | #import "CNLiveENTabBarController.h" |
| 10 | 10 | #import "XWTabBarModel.h" |
| 11 | 11 | |
| 12 | -@interface CNLiveENTabBarController () | |
| 12 | +@interface CNLiveENTabBarController ()<UITabBarDelegate>{ | |
| 13 | + NSInteger _indexFlag; | |
| 14 | +} | |
| 13 | 15 | @property (nonatomic, copy) NSMutableArray *controllers; |
| 14 | 16 | |
| 15 | 17 | @end |
| ... | ... | @@ -19,7 +21,8 @@ |
| 19 | 21 | - (void)viewDidLoad { |
| 20 | 22 | [super viewDidLoad]; |
| 21 | 23 | // Do any additional setup after loading the view. |
| 22 | - | |
| 24 | + _indexFlag = 0; | |
| 25 | + | |
| 23 | 26 | [self initItemsAndViewContorllers]; |
| 24 | 27 | // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeLanguageVersion:) name:@"changeLanguageVersion" object:nil]; |
| 25 | 28 | |
| ... | ... | @@ -127,5 +130,31 @@ |
| 127 | 130 | return [self.selectedViewController supportedInterfaceOrientations]; |
| 128 | 131 | |
| 129 | 132 | } |
| 130 | - | |
| 133 | +- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{ | |
| 134 | + NSInteger index = [self.tabBar.items indexOfObject:item]; | |
| 135 | + if (_indexFlag != index) { | |
| 136 | + [self animationWithIndex:index]; | |
| 137 | + } | |
| 138 | +} | |
| 139 | +// 动画 | |
| 140 | +- (void)animationWithIndex:(NSInteger) index { | |
| 141 | + NSMutableArray * tabbarbuttonArray = [NSMutableArray array]; | |
| 142 | + for (UIView *tabBarButton in self.tabBar.subviews) { | |
| 143 | + if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) { | |
| 144 | + [tabbarbuttonArray addObject:tabBarButton]; | |
| 145 | + } | |
| 146 | + } | |
| 147 | + CABasicAnimation*pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; | |
| 148 | + pulse.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
| 149 | + pulse.duration = 0.15; | |
| 150 | + pulse.repeatCount= 1; | |
| 151 | + pulse.autoreverses= YES; | |
| 152 | + pulse.fromValue= [NSNumber numberWithFloat:0.7]; | |
| 153 | + pulse.toValue= [NSNumber numberWithFloat:1.3]; | |
| 154 | + [[tabbarbuttonArray[index] layer] | |
| 155 | + addAnimation:pulse forKey:nil]; | |
| 156 | + | |
| 157 | + _indexFlag = index; | |
| 158 | + | |
| 159 | +} | |
| 131 | 160 | @end | ... | ... |
CNLiveScioLive/Pages/Base/CNLiveTabBarController.m
| ... | ... | @@ -9,17 +9,19 @@ |
| 9 | 9 | #import "CNLiveTabBarController.h" |
| 10 | 10 | #import "XWTabBarModel.h" |
| 11 | 11 | |
| 12 | -@interface CNLiveTabBarController () | |
| 12 | +@interface CNLiveTabBarController ()<UITabBarDelegate>{ | |
| 13 | + NSInteger _indexFlag; | |
| 14 | +} | |
| 13 | 15 | @property (nonatomic, copy) NSMutableArray *controllers; |
| 14 | 16 | |
| 15 | 17 | @end |
| 16 | 18 | |
| 17 | 19 | @implementation CNLiveTabBarController |
| 18 | - | |
| 20 | +#pragma mark - life cycle | |
| 19 | 21 | - (void)viewDidLoad { |
| 20 | 22 | [super viewDidLoad]; |
| 21 | 23 | // Do any additional setup after loading the view. |
| 22 | - | |
| 24 | + _indexFlag = 0; | |
| 23 | 25 | [self initItemsAndViewContorllers]; |
| 24 | 26 | // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeLanguageVersion:) name:@"changeLanguageVersion" object:nil]; |
| 25 | 27 | |
| ... | ... | @@ -34,6 +36,7 @@ |
| 34 | 36 | // } |
| 35 | 37 | // |
| 36 | 38 | //} |
| 39 | +#pragma mark - private methods | |
| 37 | 40 | - (void)initItemsAndViewContorllers { |
| 38 | 41 | |
| 39 | 42 | NSMutableArray *viewControllerArr = [NSMutableArray array]; |
| ... | ... | @@ -71,7 +74,7 @@ |
| 71 | 74 | } |
| 72 | 75 | self.viewControllers = viewControllerArr; |
| 73 | 76 | } |
| 74 | -#pragma mark --懒加载 | |
| 77 | +#pragma mark - getters and setters | |
| 75 | 78 | - (NSMutableArray *)controllers { |
| 76 | 79 | if (!_controllers) { |
| 77 | 80 | _controllers = [NSMutableArray array]; |
| ... | ... | @@ -138,4 +141,32 @@ |
| 138 | 141 | |
| 139 | 142 | } |
| 140 | 143 | |
| 144 | +#pragma mark - UITabBarDelegate | |
| 145 | +- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{ | |
| 146 | + NSInteger index = [self.tabBar.items indexOfObject:item]; | |
| 147 | + if (_indexFlag != index) { | |
| 148 | + [self animationWithIndex:index]; | |
| 149 | + } | |
| 150 | +} | |
| 151 | +// 动画 | |
| 152 | +- (void)animationWithIndex:(NSInteger) index { | |
| 153 | + NSMutableArray * tabbarbuttonArray = [NSMutableArray array]; | |
| 154 | + for (UIView *tabBarButton in self.tabBar.subviews) { | |
| 155 | + if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) { | |
| 156 | + [tabbarbuttonArray addObject:tabBarButton]; | |
| 157 | + } | |
| 158 | + } | |
| 159 | + CABasicAnimation*pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; | |
| 160 | + pulse.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
| 161 | + pulse.duration = 0.20; | |
| 162 | + pulse.repeatCount= 1; | |
| 163 | + pulse.autoreverses= YES; | |
| 164 | + pulse.fromValue= [NSNumber numberWithFloat:0.9]; | |
| 165 | + pulse.toValue= [NSNumber numberWithFloat:1.1]; | |
| 166 | + [[tabbarbuttonArray[index] layer] | |
| 167 | + addAnimation:pulse forKey:nil]; | |
| 168 | + | |
| 169 | + _indexFlag = index; | |
| 170 | + | |
| 171 | +} | |
| 141 | 172 | @end | ... | ... |
CNLiveScioLive/Pages/Live/View/CNLiveHeaderView.m
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | @property (nonatomic, strong) UILabel *titleLabel; |
| 15 | 15 | @property (nonatomic, strong) UILabel *stateLabel;//状态 |
| 16 | 16 | @property (nonatomic, strong) UIButton *playImage;//播放 |
| 17 | -@property (nonatomic, strong) UILabel *timeLabel;//时间 | |
| 17 | +//@property (nonatomic, strong) UILabel *timeLabel;//时间 | |
| 18 | 18 | |
| 19 | 19 | @end |
| 20 | 20 | |
| ... | ... | @@ -56,12 +56,12 @@ |
| 56 | 56 | _stateLabel.layer.cornerRadius = 2; |
| 57 | 57 | [self addSubview:_stateLabel]; |
| 58 | 58 | |
| 59 | - _timeLabel = [[UILabel alloc] init]; | |
| 60 | - _timeLabel.numberOfLines = 1; | |
| 61 | - _timeLabel.lineBreakMode = NSLineBreakByTruncatingTail; | |
| 62 | - _timeLabel.textColor = [UIColor lightGrayColor]; | |
| 63 | - _timeLabel.font = [UIFont systemFontOfSize:12]; | |
| 64 | - [self addSubview:_timeLabel]; | |
| 59 | +// _timeLabel = [[UILabel alloc] init]; | |
| 60 | +// _timeLabel.numberOfLines = 1; | |
| 61 | +// _timeLabel.lineBreakMode = NSLineBreakByTruncatingTail; | |
| 62 | +// _timeLabel.textColor = [UIColor lightGrayColor]; | |
| 63 | +// _timeLabel.font = [UIFont systemFontOfSize:12]; | |
| 64 | +// [self addSubview:_timeLabel]; | |
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | return self; |
| ... | ... | @@ -70,7 +70,7 @@ |
| 70 | 70 | - (void)setModel:(CNLiveModel *)model{ |
| 71 | 71 | _model = model; |
| 72 | 72 | _titleLabel.text = @"最新发布会"; |
| 73 | - _timeLabel.text = model.liveStartDateTime; | |
| 73 | +// _timeLabel.text = model.liveStartDateTime; | |
| 74 | 74 | [_backgroundImage sd_setImageWithURL:[NSURL URLWithString:model.poster] placeholderImage:[UIImage imageNamed:@"cnlive_placeholder"]]; |
| 75 | 75 | switch ([model.status intValue]) { |
| 76 | 76 | case 0: { |
| ... | ... | @@ -160,18 +160,25 @@ |
| 160 | 160 | }]; |
| 161 | 161 | |
| 162 | 162 | [_stateLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
| 163 | - make.left.equalTo(self->_titleLabel.mas_right).with.offset(5); | |
| 164 | - make.top.equalTo(self->_backgroundImage.mas_top).with.offset(10); | |
| 165 | - make.height.offset(18); | |
| 166 | - | |
| 167 | - }]; | |
| 168 | - | |
| 169 | - [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 170 | - make.right.equalTo(self->_backgroundImage.mas_right).with.offset(-10); | |
| 163 | + make.right.equalTo(self.mas_right).with.offset(-10); | |
| 171 | 164 | make.top.equalTo(self->_backgroundImage.mas_top).with.offset(10); |
| 172 | 165 | make.height.offset(18); |
| 173 | 166 | |
| 174 | 167 | }]; |
| 168 | + | |
| 169 | +// [_stateLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 170 | +// make.left.equalTo(self->_titleLabel.mas_right).with.offset(5); | |
| 171 | +// make.top.equalTo(self->_backgroundImage.mas_top).with.offset(10); | |
| 172 | +// make.height.offset(18); | |
| 173 | +// | |
| 174 | +// }]; | |
| 175 | + | |
| 176 | +// [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 177 | +// make.right.equalTo(self->_backgroundImage.mas_right).with.offset(-10); | |
| 178 | +// make.top.equalTo(self->_backgroundImage.mas_top).with.offset(10); | |
| 179 | +// make.height.offset(18); | |
| 180 | +// | |
| 181 | +// }]; | |
| 175 | 182 | } |
| 176 | 183 | - (void)playImageClicked:(UIButton *)btn{ |
| 177 | 184 | self.block?self.block():@""; | ... | ... |