gpt4 book ai didi

ios - 设置 View 的背景颜色时如何避免平铺?

转载 作者:行者123 更新时间:2023-11-29 03:39:25 26 4
gpt4 key购买 nike

我正在尝试为我的应用程序设置背景图像,但该图像是平铺的。我该如何防止这种情况?我希望我的图像适合背景。

在CSS中我会设置NO-REPEAT;有类似的东西吗?

我尝试过这段代码:

-(IBAction)btnAddBackground
{
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"image.jpg"]];
}

最佳答案

documentation for UIView对此提出几点建议:

  • Image-based backgrounds - For views that display relatively static content, consider using a UIImageView object with gesture recognizers instead of subclassing and drawing the image yourself. Alternatively, you can also use a generic UIView object and assign your image as the content of the view’s CALayer object.

关于ios - 设置 View 的背景颜色时如何避免平铺?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18666939/

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