作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在 iOS 应用程序中,我有 250x85pt UIView。我希望它有基于图像的平铺背景。原始图像为 398x398 像素。我希望平铺我的图像。
当我运行应用程序时,我的图像平铺,但由于某种原因它缩放如下:
我使用了下面的代码来实现它:
var image = UIImage(contentsOfFile: "myfilepath.png")!
var uicolor = UIColor(patternImage: image)
uiview.backgroundColor = uicolor
你能解释一下吗1. 为什么 ios 缩放我的图像,以及2. 如何在不缩放的情况下绘制平铺图像?
最佳答案
基本上图像比您的 UIView
大。当您提供 UIColor(patternImage: image)
时,它使用图像的 1 倍大小。我们通常在笔记本电脑上使用的图像会根据其纵横比缩放到窗口大小。
所以根据您的要求缩放图像,然后将其用作背景图像。
关于ios - 如何为 UIView 制作基于图像的平铺背景,使其无法缩放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29878371/
我是一名优秀的程序员,十分优秀!