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

先上图:



这个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下载

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值