gpt4 book ai didi

iphone - 在 UIGraphics 上下文中绘制矩形不起作用

转载 作者:行者123 更新时间:2023-11-29 11:20:06 25 4
gpt4 key购买 nike

我正在尝试用一些额外的信息覆盖图像:一些文本和矩形。现在我一直在画矩形。他们只是不会出现。我究竟做错了什么?正在绘制图像本身,因此图形上下文必须正常。

- (void)drawTag:(NSString *)tag withRect:(CGRect)rect
{
// Set the color in the current graphics context for future draw operations
[[UIColor yellowColor] setStroke];
[[UIColor yellowColor] setFill];

// Create our drawing path
UIBezierPath* drawingPath = [UIBezierPath bezierPathWithRect:rect];

// actually draw it
[drawingPath stroke];
}

- (IBAction)showDetails:(id)sender
{
// draw the image
UIGraphicsBeginImageContext(self.userImage.size);
// This one shows up:
[self.userImage drawAtPoint:CGPointZero];
// This one does not:
[self drawTag:@"Test" withRect:CGRectMake(10, 10, 50, 50)];
// Show the whole thing:
self.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.imageViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:self.imageViewController animated:YES];
}

最佳答案

您应该将 UIBezierPathlineWidth 属性设置为 >= 1

关于iphone - 在 UIGraphics 上下文中绘制矩形不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7684993/

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