热更新demo

fontSizeSliderController.m 5.2KB

    // // fontSizeSliderController.m // ThePaperHD // // Created by scar1900 on 15/3/13. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "fontSizeSliderController.h" #import "fontSizeSlideCell.h" @interface fontSizeSliderController ()<fontSizeSelectDelegate> { UITapGestureRecognizer *tap; } @property(nonatomic, strong)fontSizeSlideCell *fontSizeSelectView; @end @implementation fontSizeSliderController @synthesize delegate; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor clearColor]; tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandler:)]; tap.delaysTouchesBegan = NO; tap.cancelsTouchesInView = YES; tap.numberOfTouchesRequired = 1; [self.view addGestureRecognizer:tap]; [self.view addSubview:self.fontSizeSelectView]; } - (fontSizeSlideCell*)fontSizeSelectView { if (!_fontSizeSelectView) { _fontSizeSelectView = [[fontSizeSlideCell alloc]initWithFrame:CGRectMake(0, -220, rect_screen.size.width, 220)]; _fontSizeSelectView.delegate = self; } return _fontSizeSelectView; } - (void)dismissSelf { if ([self.delegate respondsToSelector:@selector(clickToDismiss)]) { [self.delegate clickToDismiss]; } } - (void)didFinishSelectFont { if ([self.delegate respondsToSelector:@selector(contentFontSizeHasChange)]) { [self.delegate contentFontSizeHasChange]; } } - (void)reflashSize:(CGFloat)size { [self.fontSizeSelectView setFontSize:size]; self.fontSizeSelectView.nightButton.selected = [[TPUserDefault instance].isNightMode boolValue]; /** * bug:5060(夜间模式,新闻详情页通过强关系或继续阅读切换新闻后,设置日夜间模式无效) */ } - (void)showfontSizeSliderCellFinishedWithCompletion:(void (^)(BOOL))completion { tap.enabled = NO; CGRect rect = _fontSizeSelectView.frame; rect.origin.y = -10; _fontSizeSelectView.hidden = NO; if ([UIView respondsToSelector:@selector(animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)]) { [UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:0.7 initialSpringVelocity:4.0 options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut animations:^{ _fontSizeSelectView.frame = rect; } completion:^(BOOL finished) { completion(finished); tap.enabled = YES; }]; } else { [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut animations:^{ _fontSizeSelectView.frame = rect; } completion:^(BOOL finished) { completion(finished); }]; } } - (void)dismissfontSizeSliderCellFinishCompletion:(void (^)(BOOL))completion { tap.enabled = NO; CGRect rect = _fontSizeSelectView.frame; rect.origin.y = 0; [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut animations:^ { _fontSizeSelectView.frame = rect; } completion:^(BOOL finished) { CGRect rect1 = _fontSizeSelectView.frame; rect1.origin.y = -220; [UIView animateWithDuration:0.3 animations:^ { _fontSizeSelectView.frame = rect1; } completion:^(BOOL finished) { _fontSizeSelectView.hidden = YES;; completion(finished); }]; }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)changeStauesBarStyle { [self setNeedsStatusBarAppearanceUpdate]; /** * bug:5072(新闻详情页,切换夜间日间模式,顶部ios状态栏没有反色) */ } #pragma mark - tap gesture - (void)tapHandler:(UITapGestureRecognizer *)sender { if ([sender locationInView:self.fontSizeSelectView].y < CGRectGetHeight(self.fontSizeSelectView.frame)) { return; } if ([self.delegate respondsToSelector:@selector(clickToDismiss)]) { [self.delegate clickToDismiss]; } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end