ios - 如何在IOS中翻转贺卡
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>已结束。</b>此问题不符合 <a href="https://stackoverflow.com/help/closed-questions" rel="noreferrer noopener nofollow">Stack Overflow guidelines</a> .它目前不接受答案。
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><strong>我已经为你编写了这段代码。</strong></p>
<p>*把这个放到.pch文件中</p>
<h1>定义 DEGREES_TO_RADIANS(d) (d * M_PI/180)</h1>
<p>别忘了添加和导入 QuartzCore 框架*</p>
<pre><code> #import "MyViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface MyViewController (){
CATransform3D intialTransform;
CATransform3D middelTransform;
CATransform3D finalTransform;
}
@property(nonatomic,strong) UIView *myView1;
@property(nonatomic,strong) UIView *myView2;
@end
@implementation MyViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = ;
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
;
UIButton *myButton =[initWithFrame:CGRectMake(300, 100, 120, 50)];
;
;
];
;
_myView1 = [initWithFrame:CGRectMake(400, 200, 200, 300)];
];
;
UILabel *myLabel = [initWithFrame:CGRectMake(10, 150, 100, 100)];
;
];
];
;
;
intialTransform = CATransform3DIdentity;
intialTransform.m34 = 1.0 / -500;
intialTransform = CATransform3DRotate(intialTransform, DEGREES_TO_RADIANS(70), 1.0f, 0.0f, 0.0f);
_myView1.layer.transform = intialTransform;
_myView2 = [initWithFrame:CGRectMake(400, 200, 200, 300)];
];
;
_myView2.layer.transform = intialTransform;
middelTransform = CATransform3DIdentity;
middelTransform.m34 = 1.0 / -500;
middelTransform = CATransform3DRotate(middelTransform, DEGREES_TO_RADIANS(70), 1.0f, 0.0f, 0.0f);
middelTransform = CATransform3DRotate(middelTransform, DEGREES_TO_RADIANS(-100), 0.0f, 1.0f, 0.0f);
middelTransform = CATransform3DTranslate(middelTransform,116, 0,100);
finalTransform = CATransform3DIdentity;
finalTransform.m34 = 1.0 / -500;
finalTransform = CATransform3DRotate(finalTransform, DEGREES_TO_RADIANS(70), 1.0f, 0.0f, 0.0f);
finalTransform = CATransform3DRotate(finalTransform, DEGREES_TO_RADIANS(-170), 0.0f, 1.0f, 0.0f);
finalTransform = CATransform3DTranslate(finalTransform,198, 0,16);
}
-(void)unfoldGreeting:(UIButton *)iSender{
[UIView animateWithDuration:1.0f animations:^{
_myView2.layer.transform = middelTransform;
} completion:^ (BOOL iFinished) {
[UIView animateWithDuration:1.0f animations:^{
_myView2.layer.transform = finalTransform;
}completion:nil];
}];
}
</code></pre>
<p><strong>希望这会对您有所帮助。</strong></p></p>
<p style="font-size: 20px;">关于ios - 如何在IOS中翻转贺卡,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18587125/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18587125/
</a>
</p>
页:
[1]