gpt4 book ai didi

ios - 如何平铺图像

转载 作者:行者123 更新时间:2023-12-01 19:09:10 25 4
gpt4 key购买 nike

我正在使用Xamarin开发iPhone应用程序。

我有一个1x2像素的图像,我想垂直平铺以在xib中形成虚线,但是我看不到任何简单的方法来做到这一点。 Xcode没有可用于 slice 的内容模式,尽管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。

关于ios - 如何平铺图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17790734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com