- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 jpg 图像,在矩形中有一个圆形物体,我想使圆形物体的环境透明...
(本例去除红色区域)
借助这个iOS make part of an UIImage transparent和“UIBezierPath bezierPathWithOvalInRect”我取得了一些成功,但这在我的对象周围形成了一条路径,我需要反转它,使路径的外部而不是内部透明..
我不确定我必须在哪里更改我的代码才能获得正确的结果..
Đây là mã của tôi:
//BezierPath
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 100, 100)];
// Create an image context containing the original UIImage.
UIGraphicsBeginImageContext(_imgTemp.image.size);
[_imgTemp.image drawAtPoint:CGPointZero];
// Clip to the bezier path and clear that portion of the image.
CGContextRef ngữ cảnh = UIGraphicsGetCurrentContext();
CGContextAddPath(context,bezierPath.CGPath);
CGContextClip(context);
CGContextClearRect(context,CGRectMake(0,0,self._imgTemp.image.size.width,self._imgTemp.image.size.height));
// Build a new UIImage from the image context.
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self._imgTemp.image = newImage;
有人解决了吗?
1 Câu trả lời
要仅在黑色圆圈内绘制,您应该将 [_imgTemp.image drawAtPoint:CGPointZero];
Di chuyển đến CGContextClip(context);
之后,然后删除 CGContextClearRect( ... )
完全调用:
//BezierPath
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 100, 100)];
// Create an image context containing the original UIImage.
UIGraphicsBeginImageContext(_imgTemp.image.size);
// Clip to the bezier path and clear that portion of the image.
CGContextRef ngữ cảnh = UIGraphicsGetCurrentContext();
CGContextAddPath(context,bezierPath.CGPath);
CGContextClip(context);
// Draw here when the context is clipped
[_imgTemp.image drawAtPoint:CGPointZero];
// Build a new UIImage from the image context.
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self._imgTemp.image = newImage;
关于iOS:逆 UIBezierPath (bezierPathWithOvalInRect),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10042087/
我在自定义 UIView 的 drawRect 中画了一个圆: - (void)drawRect:(CGRect)rect { ... UIBezierPath *ovalPath = [UI
Tôi có một hình ảnh jpg với một vật thể hình tròn trong một hình chữ nhật và tôi muốn làm cho môi trường của vật thể hình tròn đó trở nên trong suốt... (xóa vùng màu đỏ trong ví dụ này) Với iOS này, hãy làm cho một phần của UIImage trở nên trong suốt và "UIBe
我有以下代码: - (void)drawRect:(NSRect)dirtyRect { [[NSBezierPath bezierPathWithOvalInRect:[self theRec
在我的 UITableViewController的单元格,我想显示一个带有数字的圆圈。我正在使用 UIBezierPath的bezierPathWithOvalInRect:画圆。 不幸的是,虽然我
Tôi là một lập trình viên xuất sắc, rất giỏi!