【发布时间】:2016-10-26 15:06:46
【问题描述】:
我的 Storyboard 中有以下设置:
UIView -> UIScrollView->UIView(MyOwnView)
我有一个 UIViewController 并添加了一个 UIScrollView,在 UIScrollView 中我添加了一个 UIView。这个 UIView 是一个自定义的 UIView:
class MyOwnView: UIView {
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
self.backgroundColor = UIColor(patternImage: (UIImage(named: "menschVorne")?.resize(CGSize(width: rect.width, height: rect.height)))!)
print("loaded")
}
}
当我加载 UIViewController 时,没有显示任何图像。当 UIViewController 出现时会调用 draw(rect..) 函数。有人可以帮我吗?
致以诚挚的问候!
【问题讨论】:
-
你的scrollView设置
ContentSize了吗?见here -
是的,这一切都设置正确。我在这个 UIView 中绘制。如果我与 UIView 交互(点击它),则图像显示正确。