iPhone 代码实现横向 纵向 转换

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{


}

 

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];

self.view.transform = transform;

这里要把view 旋转.

配合一起使用

 

[原文链接:http://blog.sina.com.cn/s/blog_5730da6b0100h6z9.html]

//纵向转横向,带电池状态栏,由320*460改为480*300
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];

- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle{
CGAffineTransform transform = CGAffineTransformMakeRotation(-3.14159/2);
self.view.transform = transform;
CGPoint center = self.view.window.center;
[self.view setCenter:CGPointMake(center.x+170, center.y+220)];
[super initWithNibName:nibName bundle:nibBundle];

self.chart.parent = self;

return self;
}

 

//横向转纵向,带电池状态栏,由480*300改为320*460
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle{
CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
self.view.transform = transform;
CGPoint center = self.view.window.center;
[self.view setCenter:CGPointMake(center.x+230, center.y+140)];
[super initWithNibName:nibName bundle:nibBundle]; 
return self;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值