你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> ios如果寫一個提示帶動畫的View,可以來引導用戶行為

ios如果寫一個提示帶動畫的View,可以來引導用戶行為

編輯:IOS開發綜合

先上圖:

\


這個UIView可以這樣寫:

<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHByZSBjbGFzcz0="brush:java;">-(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下載

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved