iOS CGAffineTransform on UIView


// view controller implementation
@property (weak, nonatomic) IBOutlet UIView *v;
@end
@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
     // Do any additional setup after loading the view, typically from a nib.
     //self.v.layer.backgroundColor = [UIColor blackColor].CGColor;
     CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_4);
     self.v.layer.affineTransform = transform;
}
@end

我已经成功地将UIView *v连接到接口构建器中的UIView对象。但是由于某种原因,当self.v.layer.affineTransform = transform;被执行时,当我构建并运行v时,它从屏幕上消失了。这有什么不对吗?我该怎么解决这个问题?另外,我将对象的背景色设置为蓝色,以便在屏幕上可见。

self.v.transform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI_4);

试试这个。

最新更新