1
A
回答
2
下面应该工作:
tableView.backgroundColor = UIColor(patternImage: UIImage(named: "your_image_name")!)
由于功能顾名思义,一个UIColor
从您提供的图像创建。
有关更多信息,请参阅Apple文档here。
0
如果您进入故事板,您可以插入图像视图,插入图像,然后在文档大纲中,您可以将图像移动到表格上方,并将其放在它后面。然后在检查器中将tableView alpha设置为.5或者您希望的不透明。
+0
有一点需要注意的是,文字也会改变不透明度。 –
0
有趣的是,我只是做了一个教程,它有这个,但代码被用来代替图像。在雨燕2.0创建文件(姑且称之为BackgroundView)UIView
型的,在预发drawRect
函数添加以下代码:
// Change these colors to the ones you want.
let lightPurple: UIColor = UIColor(red: 0.377, green: 0.075, blue: 0.778, alpha: 1.000)
let darkPurple: UIColor = UIColor(red: 0.060, green: 0.036, blue: 0.202, alpha: 1.000)
let context = UIGraphicsGetCurrentContext()
//// Gradient Declarations
let purpleGradient = CGGradientCreateWithColors(CGColorSpaceCreateDeviceRGB(), [lightPurple.CGColor, darkPurple.CGColor], [0, 1])
//// Background Drawing
let backgroundPath = UIBezierPath(rect: CGRectMake(0, 0, self.frame.width, self.frame.height))
CGContextSaveGState(context)
backgroundPath.addClip()
CGContextDrawLinearGradient(context, purpleGradient,
CGPointMake(160, 0),
CGPointMake(160, 568),
[.DrawsBeforeStartLocation, .DrawsAfterEndLocation])
然后创建在TableViewController
一个configureView
功能,并把此行的代码它:
tableView.backgroundView = BackgroundView()
然后调用viewDidLoad
中的函数。
相关问题
- 1. UITableView的背景图像 - iOS
- 2. 如何在另一个背景图像背后设置背景?
- 3. 设计UITableView背景图像
- 4. UITableView背景图像问题
- 5. UITableView背景图片
- 6. 在一个背景图像
- 7. 从许多背景图像中创建一个背景图像
- 8. 在背景图像背景图像
- 9. iPad上UITableView的背景图像
- 10. UITableView背景中的不连续图像
- 11. 带固定图像背景的UITableView
- 12. JQuery SlideUp - 背景颜色背后图像
- 13. UITableView的背景?
- 14. 背景图片上的背景图像
- 15. 集UITableView的背景视图
- 16. iPhone UITableView图像背景当表空时
- 17. 将背景图像设置为uitableview?
- 18. iOS - UITableView非静态背景图像
- 19. UITableView背景图像阿尔法问题
- 20. UITableView不显示背景图像
- 21. 背景图像的一行
- 22. 背景图像
- 23. 背景图像
- 24. 图像背景
- 25. 图像背景
- 26. 背景图像
- 27. CSS:背景颜色的背景图像
- 28. 花式背景中的背景图像?
- 29. UITableView分组背景图片
- 30. 适合背景图像到第二个背景图像
这是有效的,但图像看起来是颠倒的?如果不是变量,该如何更改此图像的布局? – lairdkruger