硬币翻转动画效果
来源:互联网 发布:韩国聊天软件下载 编辑:程序博客网 时间:2024/05/07 03:55
效果图
示例
UIImageView *firstImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"profile.png"]];UIImageView *secondImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"second.jpg"]]; CMSCoinView *coinView = [[CMSCoinView alloc] initWithFrame:CGRectMake(50.0, 50.0, 120.0, 120.0) view:self.view primaryView:firstImageView secondaryView:secondImageView];coinView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.3];
实现类文件
// .h文件#import <UIKit/UIKit.h>@interface CMSCoinView : UIView- (id)initWithFrame:(CGRect)frame view:(UIView *)superview primaryView:(UIView *)primaryView secondaryView:(UIView *)secondaryView;@property (nonatomic, strong) UIView *primaryView;@property (nonatomic, strong) UIView *secondaryView;@property (nonatomic, assign) float spinTime;@end
// .m文件#import "CMSCoinView.h"#import <QuartzCore/QuartzCore.h>@interface CMSCoinView (){ bool displayingPrimary;}@end@implementation CMSCoinView// 初始化- (id)initWithFrame:(CGRect)frame view:(UIView *)superview primaryView:(UIView *)primaryView secondaryView:(UIView *)secondaryView{ self = [super init]; if (self) { self.frame = frame; if (superview) { [superview addSubview:self]; } // Initialization code self.primaryView = primaryView; self.secondaryView = secondaryView; displayingPrimary = YES; self.spinTime = 1.0; } return self;}#pragma mark - set方法- (void)setPrimaryView:(UIView *)primaryView{ _primaryView = primaryView; CGRect frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); self.primaryView.frame = frame; [self roundView: self.primaryView]; self.primaryView.userInteractionEnabled = YES; [self addSubview: self.primaryView]; UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(flipTouched:)]; gesture.numberOfTapsRequired = 1; [self.primaryView addGestureRecognizer:gesture]; [self roundView:self];}- (void)setSecondaryView:(UIView *)secondaryView{ _secondaryView = secondaryView; CGRect frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); self.secondaryView.frame = frame; [self roundView: self.secondaryView]; self.secondaryView.userInteractionEnabled = YES; [self addSubview: self.secondaryView]; [self sendSubviewToBack:self.secondaryView]; UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(flipTouched:)]; gesture.numberOfTapsRequired = 1; [self.secondaryView addGestureRecognizer:gesture]; [self roundView:self];}- (void)setSpinTime:(float)spinTime{ _spinTime = spinTime;}#pragma mark - 视图属性设置- (void)roundView:(UIView *)view{ view.layer.cornerRadius = (self.frame.size.height / 2); view.layer.masksToBounds = YES;}#pragma mark - 响应方法- (void)flipTouched:(UITapGestureRecognizer *)sender{ UIView *fromView = (displayingPrimary ? self.primaryView : self.secondaryView); UIView *toView = (displayingPrimary ? self.secondaryView : self.primaryView); UIViewAnimationOptions options = (displayingPrimary ? UIViewAnimationOptionTransitionFlipFromLeft : UIViewAnimationOptionTransitionFlipFromRight) + UIViewAnimationOptionCurveEaseInOut; [UIView transitionFromView:fromView toView:toView duration:self.spinTime options:options completion:^(BOOL finished) { if (finished) { displayingPrimary = !displayingPrimary; } } ];}@end
0 0
- 硬币翻转动画效果
- 文字翻转动画效果
- 制作翻转效果动画
- Android3D动画翻转效果
- Card翻转动画效果
- 翻转动画效果
- 动画翻转效果
- ios 视图动画翻转效果
- Android图片翻转动画效果
- ios 视图动画翻转效果
- android 翻转效果动画源码
- surface界面翻转动画效果
- Android 翻转动画 Rotate3dAnimation 效果
- iOS开发翻转动画效果
- Android 卡片翻转动画效果
- 翻转硬币
- 硬币翻转
- HTML5动画-翻转音乐盒效果动画
- 汇编学习笔记(三)-- 一个简单的汇编程序
- 二叉树遍历
- QT errors
- Android SQLite数据库版本升级原理解析
- dubbo学习之dubbo管理控制台装配及集成zookeeper集群部署(1)
- 硬币翻转动画效果
- UVA 11752 The Super Powers (集合打表)
- 最大匹配算法(匈牙利算法)模板
- Fragment 你应该知道的一切
- Java设计模式 通俗易懂总结
- js中易混淆知识点
- [Redis] redis-cli 命令总结
- 20160801-leetcode-vector
- Bug产生的原因有