首页 > 代码库 > ios假设写一个提示带动画的View,能够来引导用户行为
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 = http://www.mamicode.com/[NSNumber numberWithFloat:0.0f];"animateLayer"]; }
代码能够在http://download.csdn.net/detail/baidu_nod/7629687下载
ios假设写一个提示带动画的View,能够来引导用户行为
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。