【问题标题】:How to create tableview with curved frame?如何创建带有弯曲框架的表格视图?
【发布时间】:2015-07-14 11:16:38
【问题描述】:

有人知道如何创建带有弯曲框架的 UITableView,例如 iOS 上的 MacOS 下载(在 Dock 面板中)吗?

我尝试为此使用 UIBezierPath 类,但不幸的是我没有成功。例如我是这样做的:

_tableView = [[TVCurveTableView alloc] initWithFrame:CGRectMake(10, self.view.frame.size.height - 130, 70, 160)];
UIBezierPath *bezierPath = [[UIBezierPath alloc]init];
    [bezierPath moveToPoint:CGPointMake(10, self.view.frame.size.height - 10)];
    [bezierPath addLineToPoint:CGPointMake(40, (self.view.frame.size.height-10) - 160)];
    [bezierPath addLineToPoint:CGPointMake(110, (self.view.frame.size.height-10) - 160)];
    [bezierPath addLineToPoint:CGPointMake(80, (self.view.frame.size.height-10))];
    [bezierPath addLineToPoint:CGPointMake(10, (self.view.frame.size.height-10))];
    [bezierPath closePath];
    bezierPath.lineWidth = 2;
CAShapeLayer *shapeView = [[CAShapeLayer alloc] init];
    [shapeView setPath:bezierPath.CGPath];
    shapeView.strokeColor = [UIColor redColor].CGColor;
[_tableView.layer addSublayer:shapeView];

也许你有一些想法?

【问题讨论】:

  • 您可以将背景图像设置为弯曲图像以获得您想要的外观

标签: ios objective-c uitableview uibezierpath


【解决方案1】:

我的COBezierTableView 做了类似的事情,尽管不是倾斜单元格。不过,这将是一个不错的选择,所以也许我会考虑一下。如果您找到解决方案,Fell tr​​ee 也可以自己发送请求请求。 ;-)

https://github.com/knutigro/COBezierTableView

【讨论】:

  • 哦,谢谢!我会尝试使用它!
  • 请问,您的 COBezierTableView 是由 Objective-C 编写的吗?
  • 不,目前没有。我把它作为学习 Swift 的练习,但它的代码并不多,所以它应该不难翻译。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-21
  • 1970-01-01
相关资源
最近更新 更多