#import "ViewController.h"
@interface
ViewController ()
<
UITableViewDelegate
,
UITableViewDataSource
>
@property
(
nonatomic
,strong)
UITableView
* tablbleView;
@end
@implementation
ViewController
- (
void
)viewDidLoad {
[
super
viewDidLoad];
[
self
.view addSubview:
self
.tablbleView];
}
- (
UITableView
*)tablbleView{
if
(_tablbleView ==
nil
) {
_tablbleView = [[
UITableView
alloc]initWithFrame:
self
.view.bounds];
_tablbleView.delegate =
self
;
_tablbleView.separatorColor = [
UIColor
brownColor];
}
return
_tablbleView;
}
- (CGFloat)tableView:(
UITableView
*)tableView heightForRowAtIndexPath:(
NSIndexPath
*)indexPath{
return
60;
}
- (
NSInteger
)tableView:(
UITableView
*)tableView numberOfRowsInSection:(
NSInteger
)section{
return
6;
}
- (
UITableViewCell
*)tableView:(
UITableView
*)tableView cellForRowAtIndexPath:(
NSIndexPath
*)indexPath{
static
NSString
* cellid = @
"nihao"
;
UITableViewCell
*cell = [tableView dequeueReusableCellWithIdentifier:cellid];
if
(cell ==
nil
) {
cell = [[
UITableViewCell
alloc]initWithStyle:
UITableViewCellStyleDefault
reuseIdentifier:cellid];
cell.backgroundColor = [
UIColor
clearColor];
}
return
cell;
}
-(
void
)viewDidLayoutSubviews
{
[
super
viewDidLayoutSubviews];
if
([
self
.tablbleView respondsToSelector:
@selector
(setSeparatorInset:)]) {
[
self
.tablbleView setSeparatorInset:
UIEdgeInsetsZero
];
}
if
([
self
.tablbleView respondsToSelector:
@selector
(setLayoutMargins:)]) {
[
self
.tablbleView setLayoutMargins:
UIEdgeInsetsZero
];
}
}
-(
void
)tableView:(
UITableView
*)tableView willDisplayCell:(
UITableViewCell
*)cell forRowAtIndexPath:(
NSIndexPath
*)indexPath
{
if
([cell respondsToSelector:
@selector
(setSeparatorInset:)]) {
[cell setSeparatorInset:
UIEdgeInsetsZero
];
}
if
([cell respondsToSelector:
@selector
(setLayoutMargins:)]) {
[cell setLayoutMargins:
UIEdgeInsetsZero
];
}
}
- (
void
)didReceiveMemoryWarning {
[
super
didReceiveMemoryWarning];
}
@end