0
对于我的设计规范,我的表格视图在顶部,左侧和右侧应只有三个边框。我已经添加它使用下面的代码....为UITableView设置三面边框 - IOS
CGSize mainViewSize = menu_table.bounds.size;
CGFloat borderWidth = 1;
UIColor *borderColor = [UIColor lightGrayColor];
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, borderWidth, mainViewSize.height)];
UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(mainViewSize.width - borderWidth, 0, borderWidth, mainViewSize.height)];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mainViewSize.width, borderWidth)];
leftView.opaque = YES;
rightView.opaque = YES;
topView.opaque = YES;
leftView.backgroundColor = borderColor;
rightView.backgroundColor = borderColor;
topView.backgroundColor = borderColor;
// for bonus points, set the views' autoresizing mask so they'll stay with the edges:
leftView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin;
rightView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin;
topView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
[menu_table addSubview:leftView];
[menu_table addSubview:rightView];
[menu_table addSubview:topView];
它工作正常,但是当我滚动表,子视图添加也向上移动。我不知道为什么子视图正在移动单元格,而是应该修复表,任何想法是什么问题,以及如何解决与表视图大小。感谢名单。
感谢您的建议,我会尽力。 – Newbee
我已经尝试了,现在的问题是我在桌子底部保留了一些图像,如果向上滚动,一旦行向上移动,表格中的空白空间没有边框,并且它没有触摸该图像,因为它具有单元格。看起来奇怪。 – Newbee
你可以附上它的截图! –