我正在开发一个包含一些视图的游戏(作为存储卡游戏),我希望当用户点击卡片时这个翻转并显示另一个视图.我用这个代码:
- (void)flipCard:(id)sender {
UIButton *btn=(UIButton *)sender;
UIView *view=[btn superview];
UIView *flipView=[[UIView alloc] initWithFrame:[view frame]];
[flipView setBackgroundColor:[UIColor blueColor]];
[[flipView layer] setCornerRadius:10];
NSLog(@"Flip card : view frame = %f, %f",view.frame.origin.x, view.frame.origin.y);
[UIView transitionFromView:view toView:flipView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
}];
}
Run Code Online (Sandbox Code Playgroud)
每个视图都有一个覆盖整个视图的透明按钮,因此当用户点击视图时点击按钮.按钮调用上面传递发送方的方法.当动画开始时,所有视图都被翻转,不仅是我从发送者那里获得的视图.我能怎么做?
可能重复:
在android上实现页面卷曲?
如何在android中翻页/翻页或卷曲动画?有可能与cocos2d.如果您知道,请提供任何链接或示例.
如何在javascript中翻转布尔变量的值,而不必两次包含变量名?所以
foobarthings[foothing][barthing] = !foobarthings[foothing][barthing];
Run Code Online (Sandbox Code Playgroud)
没有写foobarthings[foothing][barthing]两次.
我们都知道如何使用创建动画的这篇文章.但我该怎么做呢?"card filp"new apion apis < 3.0
更新:
只要有像android-FlipView这样的好用且易于使用的库,我认为你真的不需要经历如此艰难的方式......
我试图翻转和ImageView垂直,但它不会工作.
Java的:
public static void flipImageVertically(final Bitmap bmp, final ImageView imageView) {
final Matrix matrix = new Matrix();
matrix.preScale(1.0f, -1.0f);
imageView.setImageBitmap(Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true));
}
Run Code Online (Sandbox Code Playgroud)
XML:
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/red" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这ImageView根本不是在翻转.
谁知道为什么?
我有一个主要由图像和按钮组成的控件.我想在图像背面显示图像元数据,并在按下按钮时让控件水平翻转:
即

点击"信息"按钮......

围绕轴旋转图像180度...

用元数据(或任何真实的)显示图像的"后退".
显然,当点击红色"关闭"按钮时,图像围绕最后的180度旋转,以便再次显示图像.
我在XAML中没有做任何3D,但我不明白为什么这会太复杂......
我正在使用画布来显示一些精灵,我需要水平翻转一个(所以它面向左或右).但是,我无法看到任何方法drawImage.
这是我的相关代码:
this.idleSprite = new Image();
this.idleSprite.src = "/game/images/idleSprite.png";
this.idleSprite.frameWidth = 28;
this.idleSprite.frameHeight = 40;
this.idleSprite.frames = 12;
this.idleSprite.frameCount = 0;
this.draw = function() {
if(this.state == "idle") {
c.drawImage(this.idleSprite, this.idleSprite.frameWidth * this.idleSprite.frameCount, 0, this.idleSprite.frameWidth, this.idleSprite.frameHeight, this.xpos, this.ypos, this.idleSprite.frameWidth, this.idleSprite.frameHeight);
if(this.idleSprite.frameCount < this.idleSprite.frames - 1) { this.idleSprite.frameCount++; } else { this.idleSprite.frameCount = 0; }
} else if(this.state == "running") {
c.drawImage(this.runningSprite, this.runningSprite.frameWidth * this.runningSprite.frameCount, 0, this.runningSprite.frameWidth, this.runningSprite.frameHeight, this.xpos, this.ypos, this.runningSprite.frameWidth, this.runningSprite.frameHeight);
if(this.runningSprite.frameCount < this.runningSprite.frames - 1) { this.runningSprite.frameCount++; …Run Code Online (Sandbox Code Playgroud) 请考虑下面的代码,并告诉我我做错了什么.
我想在两个UIViews之间翻转.
不知何故,当我从初始视图中移开时,我只是得到翻转的视图,没有动画.当我回头时,动画显示就好了.
翻转是从视图本身的按钮触发的.
- (IBAction)showMoreInfo:(id)sender
{
UIView *moreInfo = self.flipView;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
UIView *parent = self.view.superview;
[self.view removeFromSuperview];
[parent addSubview:moreInfo];
[UIView commitAnimations];
}
- (IBAction)showLessInfo:(id)sender
{
UIView *lessInfo = self.view;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.flipView cache:YES];
UIView *parent = self.flipView.superview;
[self.flipView removeFromSuperview];
[parent addSubview:lessInfo];
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud) 我知道这可能是一个虚假的问题,但我不得不问:如何UIView垂直翻转?我不是要求做动画,而只是翻动它.
我可以UILabel通过以下方式进行垂直翻转:
label1.layer.transform = CATransform3DMakeRotation(M_PI, 1.0f, 0.0f, 0.0f);
并通过以下方式将其转回:
label1.layer.transform = CATransform3DMakeRotation(M_PI, 0.0f, 0.0f, 0.0f);
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时:
self.view.layer.transform = CATransform3DMakeRotation(M_PI, 1.0f, 0.0f, 0.0f);
Run Code Online (Sandbox Code Playgroud)
我认为它只会旋转一半...所以,任何想法?
多谢你们.