xamarin - 无法对 UIImageView 应用多重转换

标签 xamarin xamarin.ios

我不明白为什么我的转换没有应用于 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/

相关文章:

ios - 如何在不加载图像文件的情况下获取图像文件的图像大小?

ios - 在 mac 中启动 iOS 模拟器失败

android - Xamarin Android Player 显示 0 个可下载设备?

c# - Xamarin Gcm 网络管理器等待 httpclient

xamarin.ios - UITableView RowSelected 没有被调用?

android - 在 Xamarin 中处理按钮单击事件

xamarin.ios - 用于 Mono 开发的 QuartzCore.framework

ios - UITableViewRowAction 限制大小

c# - Xamarin.iOS 中的静音

c# - 未调用 Xamarin.iOS RegisteredForRemoteNotifications