If ios writes a View with an animation prompt, it can guide user behavior.

Source: Internet
Author: User

If ios writes a View with an animation prompt, it can guide user behavior.

First:



This UIView can be written as follows:

-(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];}

Then, in the pop-up window:

-(Void) showTipView {CGRect rect = [[HomePageUIManager sharedInstance] region]; PopUpMenu * menu = [[PopUpMenu alloc] initWithFrame: rect backImage: [UIImage imageNamed: @ "change_search_tip.png"] msgStr: @ "open/close panel" 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; // animation duration jumpAnimation. repeatCount = 10; // Number of animation repetitions jumpAnimation. autoreverses = YES; // whether to automatically repeat [menu. layer addAnimation: jumpAnimation forKey: @ "animateLayer"];}

The code can be downloaded at http://download.csdn.net/detail/baidu_nod/7629687.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.