在我的AppDelegate中,我设置了UITableView的外观,比如背景和rowHeight等等,但不知怎么的,它并不适用于separatorStyle。它不起作用有什么原因吗?还是这是个bug?我在ViewController中设置tableView.separatorStyle = .None本身没有问题。
我的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相比,头也没有任何不同。
发布于 2015-04-23 19:14:59
这没有什么“奇怪”、“不工作”或“小马车”。并不是所有的东西都是外观与代理兼容的。查看标题:
@property (nonatomic) UITableViewCellSeparatorStyle separatorStyle; // default is UITableViewCellSeparatorStyleSingleLine
@property (nonatomic, retain) UIColor *separatorColor UI_APPEARANCE_SELECTOR; // default is the standard separator gray注意到什么了吗?separatorColor标记为UI_APPEARANCE_SELECTOR。separatorStyle不是。这意味着您可以在外观代理中使用separatorColor,而不能在外观代理中使用separatorStyle。
https://stackoverflow.com/questions/29832119
复制相似问题