我不明白为什么我的转换没有应用于 Xamarin iOS 中的 UIImageView。
代码如下:
CGAffineTransform transform = new CGAffineTransform();
transform.Rotate((float)Math.PI / 2);
transform.Scale(0.8f, 0.8f);
this.imageViewOverlay = new UIImageView
{
ContentMode = UIViewContentMode.Center,
BackgroundColor = UIColor.Clear,
Opaque = false,
Frame = new CGRect(0,0,this.View.Bounds.Width, this.View.Bounds.Height),
Transform = transform
};
我以前的做法是这样的
Transform = CGAffineTransform.MakeRotation((float)Math.PI / 2)
但不幸的是,当你想使用它两次时,第二次是清除之前的转换。
我正在使用
Xamarin.iOS: 版本:8.6.0.41(商业版)
操作系统: Mac OS X 10.10.3
XCode:版本 6.3.1 (6D1002)
谢谢!
最佳答案
您的原始 CGAffineTransform
为空(全部为 00
),默认为结构体,并且不是身份转换,最重要的是你可以 build 一些东西。 IOW 使所有后续调用(数学操作)返回一个空的。
您可以从非空转换开始,例如
var transform = CGAffineTransform.MakeRotation((float)Math.PI / 2);
transform.Scale(0.8f, 0.8f);
或者您可以从身份转换开始,例如
var transform = CGAffineTransform.MakeIdentity ();
transform.Rotate ((nfloat) Math.PI / 2);
transform.Scale ((nfloat) 0.8f, (nfloat) 0.8f);
关于xamarin - 无法对 UIImageView 应用多重转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30140444/