【发布时间】:2016-08-24 13:31:14
【问题描述】:
【问题讨论】:
-
你试过改变图像的方向吗?
-
我不想这样做,我不想为不同的方向保留四个不同的图像。
标签: ios objective-c uibutton uideviceorientation
【问题讨论】:
标签: ios objective-c uibutton uideviceorientation
如果你有一个 IBOutlet 对象。
theButton.transform = CGAffineTransformMakeRotation(M_PI / -4);
如果你想在视图上创建运行时按钮。
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(100, 100, 200, 44)];
btn.transform=CGAffineTransformMakeRotation(M_PI / -4);
[btn setTitle:@"RakeshBhatt" forState:UIControlStateNormal];
[self.view addSubview:btn];
}
【讨论】:
要旋转图像视图试试这个
// Set the anchor point and center so the view swings from the upper right
imageView.layer.anchorPoint = CGPointMake(1.0, 0.0);
imageView.center = CGPointMake(CGRectGetWidth(self.view.bounds), 0.0);
// Rotate 90 degrees to hide it off screen
CGAffineTransform rotationTransform = CGAffineTransformIdentity;
rotationTransform = CGAffineTransformRotate(rotationTransform, DegreesToRadians(90));
swingView.transform = rotationTransform;
【讨论】: