【发布时间】:2015-04-23 18:59:46
【问题描述】:
在我的 AppDelegate 中,我设置了 UITableView 的外观,例如背景和 rowHeight 等。但不知何故,它不适用于separatorStyle。是否有任何原因导致它不起作用或者这是一个错误?我在 ViewController 本身中使用 tableView.separatorStyle = .None 设置 separatorStyle 没有问题。
我的 AppDelegate 中的代码:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.statusBarHidden = true
UIToolbar.appearance().barTintColor = UIColor.grayColor()
UITableView.appearance().backgroundColor = UIColor.blackColor()
UITableView.appearance().rowHeight = 40
UITableView.appearance().separatorStyle = .None
UITableViewCell.appearance().backgroundColor = UIColor.clearColor()
return true
}
奇怪的是,separatorColor 确实有效。
编辑:
当我查看UITableView 时,会显示:
// Appearance
var sectionIndexMinimumDisplayRowCount: Int // show special section index list on right when row count reaches this value. default is 0
@availability(iOS, introduced=6.0)
var sectionIndexColor: UIColor? // color used for text of the section index
@availability(iOS, introduced=7.0)
var sectionIndexBackgroundColor: UIColor? // the background color of the section index while not being touched
@availability(iOS, introduced=6.0)
var sectionIndexTrackingBackgroundColor: UIColor? // the background color of the section index while it is being touched
var separatorStyle: UITableViewCellSeparatorStyle // default is UITableViewCellSeparatorStyleSingleLine
var separatorColor: UIColor! // default is the standard separator gray
@availability(iOS, introduced=8.0)
@NSCopying var separatorEffect: UIVisualEffect? // effect to apply to table separators
有点奇怪,因为它在评论Appearance下。与separatorColor 相比,标头也没有任何不同。
【问题讨论】:
标签: uitableview swift uiappearance