好吧,我将正弦波实现到 UIView drawrect 方法中,如下所示:
float x=75;
float yc=50;
float w=0;
while (w<=rect.frame.size.width) {
CGPathMoveToPoint(path, nil, w,y/2);
CGPathAddQuadCurveToPoint(path, nil, w+x/4, -yc,w+ x/2, y/2);
CGPathMoveToPoint(path, nil, w+x/2,y/2);
CGPathAddQuadCurveToPoint(path, nil, w+3*x/4, y+yc, w+x, y/2);
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathStroke);
w+=x;
}
这里 x 是每个正弦波的宽度,而 y 是框架的高度。这将绘制许多正弦波以适合整个 UIViewFrame。它会产生清晰的正弦波,并且 yc 是控制手柄。尝试一下你可能会喜欢它。
如果宽度即。 x 与帧的宽度相似,那么将产生单个正弦波。
完整正弦波的数量=(帧宽度)/('x'每个正弦波的宽度)