Daily Update Attention :Http://weibo.com/hanjunqiang
In the development of the cell split line is often encountered or want to customize the width of the line high; Recently summed up, hope to help everyone:
1. What if I don't want to dash?
TableView.separatorSt YLE = Uitableviewcellseparatorstylesingleline; Sets the system default line style-(void) Viewdidlayoutsubviews {if ([TableView respondstoselector: @selector (setseparatorinset:)]) { [TableView Setseparatorinset:uiedgeinsetszero]; } if ([TableView respondstoselector: @selector (setlayoutmargins:)]) {[TableView Setlayoutmargins:uiedgeinsetsze RO]; }}-(void) TableView: (UITableView *) TableView Willdisplaycell: (UITableViewCell *) cell Forrowatindexpath: (Nsindexpath *) indexpat{if ([Cell respondstoselector: @selector (setlayoutmargins:)]) {[Cell Setlayoutmargins:uiedgeinsetszer O]; } if ([Cell respondstoselector: @selector (setseparatorinset:)]) {[Cell Setseparatorinset:uiedgeinsetszero]; }}
Daily update concern :http://weibo.com/hanjunqiang
2. What if I want to set the dash?
TableView.separatorSt YLE = Uitableviewcellseparatorstylenone; Drop the line of the system, draw a custom line # define Single_line_height (1/[uiscreen mainscreen].scale)//Line height # define Color_line_gray [Uicolor Colo rwithred:224/255.0f green:224/255.0f blue:224/255.0f alpha:1]//Split Line Color #e0e0e0在自定义cell里写入:-(void) DrawRect: (CGRect) rect{Cgcontextref context = Uigraphicsgetcurrentcontext (); Cgcontextsetfillcolorwithcolor (context, [Uicolor Clearcolor]. Cgcolor); Cgcontextfillrect (context, rect); Under Split line Cgcontextsetstrokecolorwithcolor (context, Color_line_gray. Cgcolor); Color_line_gray for Line Color cgcontextstrokerect (context, CGRectMake (0, Rect.size.height, Rect.size.width, single_line_he ight)); Single_line_height is the height of the line}
Daily Update Attention :Http://weibo.com/hanjunqiang
iOS Developers Exchange QQ Group :446310206 have problems or technical exchanges can be consulted! Welcome to join !
iOS UITableViewCell cell Dash Those things Han Junqiang's blog