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

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

时间: 2024-08-05 13:55:27

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 = t

写一个android带动画效果的TabHost(类似微博客户端的切换效果)

先上图: 这个Layout是: <?xml version="1.0" encoding="UTF-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" andro

如何用PHP/MySQL为 iOS App 写一个简单的web服务器(译) PART1

原文:http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app 作为一个iPhone/iPad开发者,能够自己写一个简单的web服务器将是很有用的. 例如,你可能希望在软件启动时显示一些来自服务器的更新,或者在服务器端保存一些用户数据.除了你的想象力,没有什么能限制你了. 在第一篇中,我们将会一步一步的建立一个web服务器,基于promo code system(促销码系

自定义写一个提示框

//新创建一个类 #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger, XFNoticesStyle) { XFNoticesStyleSuccess = 0, XFNoticesStyleFail = 1, }; @interface XFNotices : UIView //创建方法 +(void)noticesWithTitle:(NSString *)title Time:(NSTimeInterval)time View:(UIView

iOS重写drawRect方法实现带箭头的View

创建一个UIView的子类,重写drawRect方法可以实现不规则形状的View,这里提供一个带箭头View的实现代码: ArrowView.h #import <UIKit/UIKit.h> @interface ArrowView : UIView @end ArrowView.m #import "ArrowView.h" @implementation ArrowView /* // Only override drawRect: if you perform cu

写一个脚本 通过字符菜单方式添加和删除用户

1.编写menu.sh脚本 #!/bin/bash # function menu(){ cat << EOF `echo -e "\033[30;47m########################################\033[0m"`                `echo -e "\033[32mMy Menu\033[0m"` `echo -e "\033[30;47m##########################

Swift 写一个简单界面(实战-新手)

原文链接 在这篇博文中你可以看到那些内容呢, 首先这是一个用tableView纯代码Swift写的简单界面, 你可以看到下面这些 - 使用Alamofire 进行网络请求 - 使用MJExtension 进行字典转模型 - 使用HanekeSwift 进行图片的赋值 - 如何写一个模型(M) - 如何自定义一个UITableViewCell Alamofire 简单网络请求 func XTNetworkReq(url: String){ print("SUMMER_TEST_1") A

Android带动画效果的弹窗

在网络加载数据的时候通常需要很多时间,这个时候程序里面经常需要写一个提示正在加载数据的弹窗,这篇文章用两种方式实现带动画效果的Dialog:帧动画实现和GIF动态图实现,它们都能达到动画的效果 第一种.帧动画实现 自定义一个Dialog,先看一下布局文件dialog_animation.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

【Android】 给我一个Path,还你一个酷炫动画

本篇文章已授权微信公众号 hongyangAndroid (鸿洋)独家公布 转载请标明出处: http://blog.csdn.net/zxt0601/article/details/53040506 本文出自:[张旭童的CSDN](http://blog.csdn.net/zxt0601) 代码传送门:喜欢的话.随手点个star.多谢 https://github.com/mcxtzhang/PathAnimView 一 概述 原本仅仅是想模仿一下我魂牵梦萦的StoreHouse效果.没想到意