我正在使用 Xamarin 开发 iPhone 应用程序。
我有一个 1x2 像素的图像,我想垂直平铺以在 a 中形成一条虚线xib
,但我没有看到任何简单的方法来做到这一点。Xcode 没有用于平铺的内容模式,虽然 Xamarin 中的UIImage类具有ResizingMode属性,但它是只读的!
有没有一种理智的方法来完成这项工作?
我正在使用 Xamarin 开发 iPhone 应用程序。
我有一个 1x2 像素的图像,我想垂直平铺以在 a 中形成一条虚线xib
,但我没有看到任何简单的方法来做到这一点。Xcode 没有用于平铺的内容模式,虽然 Xamarin 中的UIImage类具有ResizingMode属性,但它是只读的!
有没有一种理智的方法来完成这项工作?
怎么样:
UIView tiledView = new UIView();
UIImage image = UIImage.FromFile("your_image.png");
tiledView.BackgroundColor = UIColor.FromPatternImage(image);
在 UITableViewCell 上,BackgroundColor 属性不可用,因为它被 UITableView 覆盖。我做的解决方法是:
private UIView background;
public override void AwakeFromnib() {
base.AwakeFromNib();
this.background = new UIView();
this.background.BackgroundColor = UIColor.Blue;
this.AddSubview(this.background);
}
public override void LayoutSubviews() {
base.LayoutSubviews();
this.background.Frame = this.Bounds;
}
只需根据您的需要更改 BackgroundColor。