gpt4 book ai didi

iphone - 我如何在 self.view 中调用这个方法?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:52:08 25 4
gpt4 key购买 nike

我正在制作这种画线的方法,现在我想要的是在另一种方法中调用它,我该怎么做,请帮我解决这个问题,我该如何在 self.view 中添加它?

- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetLineWidth(context, 5.0);

CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

CGFloat dashArray[] = {2,6,4,2};

CGContextSetLineDash(context, 3, dashArray, 4);

CGContextMoveToPoint(context, 10, 200);

CGContextAddQuadCurveToPoint(context, 150, 10, 300, 200);

CGContextStrokePath(context);

}

最佳答案

将 View 标记为需要重绘:

[self.view setNeedsDisplay];

参见 reference .

关于iphone - 我如何在 self.view 中调用这个方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16936141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com