为了账号安全,请及时绑定邮箱和手机立即绑定

如何在iPhone上画线?

如何在iPhone上画线?

杨魅力 2019-11-13 15:45:09
我是iPhone编程的初学者,为了在Quartz和UIKit中学习,我想在电话屏幕上画一条线。如何开始绘图?
查看完整描述

2 回答

?
哈士奇WWW

TA贡献1799条经验 获得超6个赞

您也可以使用绘制一条线UIBezierPath。下面将绘制垂直居中的水平线:


- (void)drawRect:(CGRect)rect {

    CGFloat rectHeight = CGRectGetHeight(rect);

    CGFloat rectWidth = CGRectGetWidth(rect);


    UIBezierPath *line = [UIBezierPath bezierPath];

    [line moveToPoint:CGPointMake(0, rectHeight / 2)];

    [line addLineToPoint:CGPointMake(rectWidth, rectHeight / 2)];


    [[UIColor lightGrayColor] setStroke];

    [line stroke];

}

分享编辑


查看完整回答
反对 回复 2019-11-13
  • 2 回答
  • 0 关注
  • 541 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信