开发者

iPhone: TableView separator

I know that iPhone SDK can set a color to the TableView separator like this:

myTableView.style = UITableViewStylePlain;
myTableView.separatorStyle = 开发者_如何学PythonUITableViewCellSeparatorStyleSingleLine;
myTableView.separatorColor = [UIColor blackColor];

Is there any way to set gradient color to separator ? Thanks...


You can make the separator style UITableViewCellSeparatorStyleNone and apply a one point wide line to the bottom of each cell, which is a gradient.

The only problem is that it might look odd on tableviews with fewer cells than fit on the screen when the table view has a plain style, but I don't know how to fix that.


You could draw your TableViewCells (see Loren Brichter's fast scrolling) and then add gradient drawing to your drawContentView: implementation. For details on gradient drawing, see the "Drawing with a gradient" section of the CGContext documentation.

A great side effect of this is that your tableview scrolling becomes crazy fast... but you have to draw your cells, which can get complex if your cells have very complicated view hierarchies (which you should avoid anyway).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜