gpt4 book ai didi

iphone - 如何平滑 iPhone 的标记笔划?

转载 作者:行者123 更新时间:2023-12-03 20:31:16 25 4
gpt4 key购买 nike

嗨,我正在开发一个应用程序,我必须在其中画一些东西。当我用标记描边绘制时,它会产生一些边缘,我如何才能避免这些边缘? enter image description here

enter image description here

标记笔划代码

- (void)drawRect:(CGRect)rect
{
// KidsPhotoBookAppDelegate *appDelegate = (KidsPhotoBookAppDelegate*)[[UIApplication sharedApplication]delegate];
// brushPattern = (UIColor*)appDelegate.kidsSelectedColor;

DBManager *dbMgr = [DBManager sharedManager];
[dbMgr.c setStroke];
for (UIBezierPath *_path in pathArray)
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
KidsPhotoBookAppDelegate *appDelegate = (KidsPhotoBookAppDelegate*)[[UIApplication sharedApplication]delegate];

myPath=[[UIBezierPath alloc]init];
myPath.lineWidth = appDelegate.kidsBrushSize;
myPath.lineCapStyle = kCGLineCapRound;
brushPattern=appDelegate.kidsSelectedColor;
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[myPath moveToPoint:[mytouch locationInView:self]];
[pathArray addObject:myPath];

appDelegate.viewContainsDrawing = YES;
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[myPath addLineToPoint:[mytouch locationInView:self]];

[self setNeedsDisplay];
}

最佳答案

您应该将行连接设置为 kCGLineJoinRound使用CGContextSetLineJoin功能。请参阅Quartz 2D Guide 了解更多。

更新

由于您正在使用UIBezierPath ,您应该尝试设置 lineJoinStyleUIBezierPathkCGLineJoinRound .

关于iphone - 如何平滑 iPhone 的标记笔划?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9738902/

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