【发布时间】:2016-02-24 22:13:17
【问题描述】:
我使用 UIView 扩展在我的应用中设置背景。
import UIKit
extension UIView {
func addBackground() {
// screen width and height:
let width = UIScreen.mainScreen().bounds.size.width
let height = UIScreen.mainScreen().bounds.size.height
let imageViewBackground = UIImageView(frame: CGRectMake(0, 0, width, height))
imageViewBackground.image = UIImage(named: "index_clear")
imageViewBackground.clipsToBounds = true
// you can change the content mode:
imageViewBackground.contentMode = UIViewContentMode.ScaleAspectFill
self.addSubview(imageViewBackground)
self.sendSubviewToBack(imageViewBackground)
}}
图片比 iphone 屏幕大 3-4 倍。 现在我尝试在 LaunchScreen 中设置相同的背景。在同一个位置。
我尝试在 Interface Builder 中使用 Image View 来执行此操作,但即使我选择“Aspect Fill”,图片也不在同一位置。
有什么想法吗?非常感谢您的帮助。
按要求截图
启动屏幕:
每隔一个屏幕:
@DeyaEldeen 的建议
【问题讨论】:
-
请添加两个屏幕截图,以便我们确保可以根据需要为您提供帮助。