Swift 斯威夫特:如何设置背景图像适合我的屏幕?
我设置了一个图像作为背景色,以便在图像上绘制一些线条。但是现在我无法使图像适合屏幕…我是swift的新手 我尝试将此视图的ContentMode设置为AspectFit、ScaletoFit等,它不会影响背景色图像的显示 有人能帮忙吗 以下是我在UIViewController中使用的代码: 图纸代码:Swift 斯威夫特:如何设置背景图像适合我的屏幕?,swift,colors,background,Swift,Colors,Background,我设置了一个图像作为背景色,以便在图像上绘制一些线条。但是现在我无法使图像适合屏幕…我是swift的新手 我尝试将此视图的ContentMode设置为AspectFit、ScaletoFit等,它不会影响背景色图像的显示 有人能帮忙吗 以下是我在UIViewController中使用的代码: 图纸代码: class View: UIView { func drawRooftopAtTopPointOf(point: CGPoint){ UIColor.redColor().set(
class View: UIView {
func drawRooftopAtTopPointOf(point: CGPoint){
UIColor.redColor().set()
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 5)
CGContextMoveToPoint(context, 140, 100)
CGContextAddLineToPoint(context, 140, 50)
CGContextStrokePath(context)
}您为UIImageView设置了框架吗?我想这不是UIImageView,ViewConcoller中没有任何内容,因此我没有设置框架。我只是将背景色设置为图像。如果在内部设置UIImageView,那么CGContext绘制的线条将被覆盖…我只想在图像上绘制一些线条。请问如何设置此视图的边框?我还没弄明白…每个UIView都有一个属性。对不起,能解释一下吗?我不是CS的家伙,目前还不确定财产的意义…我的坏。。。
class View: UIView {
func drawRooftopAtTopPointOf(point: CGPoint){
UIColor.redColor().set()
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 5)
CGContextMoveToPoint(context, 140, 100)
CGContextAddLineToPoint(context, 140, 50)
CGContextStrokePath(context)