码迷,mamicode.com
首页 > 移动开发 > 详细

ios如果写一个提示带动画的View,可以来引导用户行为

时间:2014-07-14 11:22:27      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:ios提示   引导用户行为   

先上图:

bubuko.com,布布扣


这个UIView可以这样写:

-(id)initWithFrame:(CGRect)frame backImage:(UIImage*)image msgStr:(NSString*)txt
          txtColor:(UIColor*)color{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        _paopaoImage = image;
        _txt = txt;
        _color = color;
        
    }
    return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGRect textRc = rect;
    [_paopaoImage drawInRect:rect];
    CGFontRef contextFont = CGFontCreateWithFontName((CFStringRef)[UIFont systemFontOfSize:14].fontName);
    CFRelease(contextFont);
    
    CGContextSetFontSize(context, 14.0);
    CGContextSetFillColorWithColor(context, _color.CGColor);
    textRc.origin.y += 11.0f;
    [_txt drawInRect:textRc withFont:[UIFont systemFontOfSize:14] lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
}

然后弹出的时候:

-(void)showTipView{
    CGRect rect = [[HomePageUIManager sharedInstance] categoryTipViewFrameWhenLaunch];
    PopUpMenu* menu = [[PopUpMenu alloc] initWithFrame:rect backImage:[UIImage imageNamed:@"change_search_tip.png"] msgStr:@"打开/关闭面板" txtColor:[CCommon RGBColorFromHexString:@"#ffffff" alpha:1.0f]];
    
    [self.view addSubview:menu];
    
    CABasicAnimation *jumpAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
    jumpAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
    jumpAnimation.toValue = [NSNumber numberWithFloat:8.0f];
    
    jumpAnimation.duration = 0.5f;//动画持续时间
    jumpAnimation.repeatCount = 10;//动画重复次数
    jumpAnimation.autoreverses = YES;//是否自动重复
    [menu.layer addAnimation:jumpAnimation forKey:@"animateLayer"];
}

代码可以在http://download.csdn.net/detail/baidu_nod/7629687下载

ios如果写一个提示带动画的View,可以来引导用户行为,布布扣,bubuko.com

ios如果写一个提示带动画的View,可以来引导用户行为

标签:ios提示   引导用户行为   

原文地址:http://blog.csdn.net/baidu_nod/article/details/37741251

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