我使用 Quartz 进行绘图,就像在自定义 UIView 中说“Paint”
我有 Controller View “viewC”
我做到了
[self.view addSubView:somePaintInstance]; in my viewC at some event
现在,当我绘图或绘画时,Paint 的默认背景是“黑色”。
我想在我的“viewC” View 上进行完全透明的绘画/绘图
所以我做到了
somePaintInstance.alpha=0.5; (before adding it as subview)
但这也使我的绘图/绘画在油漆的背景下变得透明,所以如果我将其设置为完全透明(alpha = 0.0),我将无法通过油漆的 View 看到绘图本身
我尝试过但不起作用:
- somePaintInstance.setbackgroundcolor
- somePaintInstance.opaque
网络上的其他答案对于这种实现也并不具体
我在这里查看了 rob 的答案: How to add a transparent gradient mask to a context
但仍然不清楚如何实现我想要的?
如果需要,请告诉我其他详细信息
问候,
最佳答案
我尝试设置 alpha 值为 0 的背景或使用 StartTransparentLayer。这些都不起作用。 对我有用的是将 View 不透明属性设置为“否”。 在我的 View 的初始化程序中,我放置了以下代码:
-(id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// set default values
self.colorNormal = [UIHelper ricolaYellow];
self.colorActice = [UIColor colorWithHexString:CIRCLE_COLOR_ACTIVE];
self.capacities = nil;
self.opaque = NO;
}
return self;
}
关于ios - 如何使完全透明 View 上的绘图可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9679934/