ios动画两个视图变换问题
贴代码//.m文件@interfacelimingViewController()@property(weak,nonatomic)IBOutletUILabel*cou...
贴代码
//.m文件
@interface limingViewController ()
@property (weak, nonatomic) IBOutlet UILabel *count;
@property (weak, nonatomic) IBOutlet UIButton *button1;
@property (weak, nonatomic) IBOutlet UIButton *button2;
@property (weak, nonatomic) IBOutlet UIButton *button3;
@end
@implementation limingViewController
-(id) firstview
{
if(!_firstview)
{
_firstview=[[UIView alloc]initWithFrame:CGRectMake(65, 100, 200, 100)];
_firstview.backgroundColor=[UIColor redColor];
}
return _firstview;
}
-(id) secondview
{
if (!_secondview) {
_secondview=[[UIView alloc]init];
_secondview.backgroundColor=[UIColor blueColor];
}
return _secondview;
}
-(id) thirdview
{
if (!_thirdview) {
_thirdview=[[UIView alloc]init];
_thirdview.backgroundColor=[UIColor blackColor];
}
return _thirdview;
}
- (void)viewDidLoad
{
UIView *containview=[[UIView alloc]initWithFrame:self.firstview.frame];
self.firstview.frame=containview.bounds;
self.secondview.frame=containview.bounds;
self.thirdview.frame=containview.bounds;
[containview addSubview:self.secondview];
[containview addSubview:self.thirdview];
[containview addSubview:self.firstview];
[self.view addSubview:containview];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)redButton:(id)sender {
self.count1++;
self.count.text=[NSString stringWithFormat:@"Count:%d",self.count1];
[UIView transitionFromView:self.firstview toView:self.secondview duration:2 options:UIViewAnimationOptionTransitionFlipFromLeft|UIViewAnimationOptionShowHideTransitionViews completion:^(BOOL finished)
{}];
}
我想把第一个视图由动画的方式变换成第二个视图。但是为什么每次变换是会变成第三个视图。求大神告知。感激不尽。 展开
//.m文件
@interface limingViewController ()
@property (weak, nonatomic) IBOutlet UILabel *count;
@property (weak, nonatomic) IBOutlet UIButton *button1;
@property (weak, nonatomic) IBOutlet UIButton *button2;
@property (weak, nonatomic) IBOutlet UIButton *button3;
@end
@implementation limingViewController
-(id) firstview
{
if(!_firstview)
{
_firstview=[[UIView alloc]initWithFrame:CGRectMake(65, 100, 200, 100)];
_firstview.backgroundColor=[UIColor redColor];
}
return _firstview;
}
-(id) secondview
{
if (!_secondview) {
_secondview=[[UIView alloc]init];
_secondview.backgroundColor=[UIColor blueColor];
}
return _secondview;
}
-(id) thirdview
{
if (!_thirdview) {
_thirdview=[[UIView alloc]init];
_thirdview.backgroundColor=[UIColor blackColor];
}
return _thirdview;
}
- (void)viewDidLoad
{
UIView *containview=[[UIView alloc]initWithFrame:self.firstview.frame];
self.firstview.frame=containview.bounds;
self.secondview.frame=containview.bounds;
self.thirdview.frame=containview.bounds;
[containview addSubview:self.secondview];
[containview addSubview:self.thirdview];
[containview addSubview:self.firstview];
[self.view addSubview:containview];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)redButton:(id)sender {
self.count1++;
self.count.text=[NSString stringWithFormat:@"Count:%d",self.count1];
[UIView transitionFromView:self.firstview toView:self.secondview duration:2 options:UIViewAnimationOptionTransitionFlipFromLeft|UIViewAnimationOptionShowHideTransitionViews completion:^(BOOL finished)
{}];
}
我想把第一个视图由动画的方式变换成第二个视图。但是为什么每次变换是会变成第三个视图。求大神告知。感激不尽。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询