水波纹实现两张图片的切换
来源:互联网 发布:斐波那契数列java 编辑:程序博客网 时间:2024/04/28 00:58
创建一个View类,实现这个View上的两张图片切换的时候出现水波纹动画。
首先,引入QuartzCore.framework系统库
.h文件:
#import <UIKit/UIKit.h>@interface AniImageView : UIView-(void)createImageView:(UIImage *)image1 secondImageView:(UIImage *)image2;//切换两张图片-(void)transformImageviews;@end
.m文件:
#import "AniImageView.h"#import <QuartzCore/QuartzCore.h>@interface AniImageView(){ CATransition *animation;}@end@implementation AniImageView- (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { animation=[CATransition animation]; animation.delegate=self; animation.duration=1.8; animation.type=@"rippleEffect"; animation.subtype=kCATransitionFromRight; } return self;}-(void)createImageView:(UIImage *)image1 secondImageView:(UIImage *)image2{ CGRect Frame=self.frame; UIImageView *imageView1=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, Frame.size.width, Frame.size.height)]; imageView1.image=image1; imageView1.tag=100; [self addSubview:imageView1]; UIImageView *imageView2=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, Frame.size.width, Frame.size.height)]; imageView2.image=image2; imageView2.tag=200; [self addSubview:imageView2]; }-(void)transformImageviews{ NSInteger front=[[self subviews]indexOfObject:[self viewWithTag:100]]; NSInteger back=[[self subviews] indexOfObject:[self viewWithTag:200]]; [self exchangeSubviewAtIndex:front withSubviewAtIndex:back]; [[self layer] addAnimation:animation forKey:@"animation"];}
使用时,创建一个AniImageView对象,添加两张图片,再调用切换图片方法即可。
0 0
- 水波纹实现两张图片的切换
- JS 两张图片的切换
- 两张图片切换脚本
- 点击两张图片切换
- android 两张图片切换
- 自定义ImageView点击实现两张图片切换
- 自定义ImageView点击实现两张图片切换
- 自定义ImageView点击实现两张图片切换
- android中Imagebutton实现两张图片之间的点击来回切换
- 实现两张图片的叠加
- PHP合并两张图片的实现
- 多张图片的左右切换特效,实现循环切换
- 两张图片切换比例虚拟进度条
- 水波形图片切换
- 利用JAVASCRIPT实现几张图片的切换
- Js实现多张图片无规律的轮流切换
- Js实现多张图片有规律的随机切换
- 使用h5的canvas实现两张图片的合并
- Managing Dynamic Memory Is Error-prone
- 裁剪相册中的图片并存储在本地
- XML的转义字符
- vim中设置python代码缩进为4个空格
- 开关按钮实现
- 水波纹实现两张图片的切换
- Android中的页面跳转详解
- Python文件操作
- Linux下Apache+SVN搭建完美版
- 如何提高产品销量?
- 格式化float输出
- 绕任意轴旋转向量
- Mel Secondary Geometry
- Mel Querying UI Widgets