码迷,mamicode.com
首页 > 其他好文 > 详细

头部显示提示,如tableview滑动提示滑回顶部

时间:2015-01-26 22:46:57      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:ios   滑动提示   

头部显示提示,如tableview滑动提示滑回顶部

by 伍雪颖

技术分享

就是在[[[UIApplication sharedApplication] delegate] window]添加要的内容:

#import "TipsBar.h"

@implementation TipsBar

UILabel *tipsLabel;
int width;
+ (
void)showInView:(UIView *)view {
   
width = view.frame.size.width;
   
if (tipsLabel == nil) {
       
tipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, -20, view.frame.size.width, 20)];
       
tipsLabel.backgroundColor = [UIColor blackColor];
       
tipsLabel.textColor = [UIColor whiteColor];
       
tipsLabel.text = @"点击返回顶部";
       
tipsLabel.font = [UIFont systemFontOfSize:12];
       
tipsLabel.textAlignment = NSTextAlignmentCenter;
    }
   
if ([[[UIApplication sharedApplication] delegate] window] != nil) {
        [[[[
UIApplication sharedApplication] delegate] window] addSubview:tipsLabel];
        [[[[
UIApplication sharedApplication] delegate] window] setWindowLevel:UIWindowLevelStatusBar];
    }
    [
UIView animateWithDuration:0.3 animations:^{
       
tipsLabel.frame = CGRectMake(0, 0, view.frame.size.width, 20);
    }];
}

+ (
void)hide {
    [
UIView animateWithDuration:0.3 animations:^{
       
tipsLabel.frame = CGRectMake(0, -20, width, 20);
    }
completion:^(BOOL finished) {
        [
tipsLabel removeFromSuperview];
       
tipsLabel = nil;
    }];
}

@end

头部显示提示,如tableview滑动提示滑回顶部

标签:ios   滑动提示   

原文地址:http://blog.csdn.net/rainlesvio/article/details/43163951

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!