- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用以下类绘制一个简单的描边圆:
@implementation StrokedCircle
- (id)initWithRadius:(CGFloat)radius strokeWidth:(CGFloat)strokeWidth strokeColor:(UIColor *)strokeColor
{
self = [super initWithRadius:radius];
if (self)
{
_strokeWidth = strokeWidth;
_strokeColor = strokeColor;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
NSLog(@"Drawing with color %@ and stroke width %f", self.strokeColor, self.strokeWidth);
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect circleRect = CGRectInset(rect, self.strokeWidth, self.strokeWidth);
CGContextAddEllipseInRect(context, circleRect);
CGContextSetLineWidth(context, self.strokeWidth);
CGContextSetStrokeColor(context, CGColorGetComponents([self.strokeColor CGColor]));
CGContextStrokePath(context);
}
@end
UIView
的子类),带有
radius
设置的属性,并且 View 的背景颜色设置为
clearColor
.
viewDidLoad
中添加以下代码:
- (void)viewDidLoad
{
[super viewDidLoad];
StrokedCircle *strokedCircle = [[StrokedCircle alloc] initWithRadius:50.0 strokeWidth:1.0 strokeColor:[UIColor blueColor]];
strokedCircle.center = self.view.center;
[self.view addSubview:strokedCircle];
}
2014-06-14 10:31:58.270 ShapeTester[1445:60b] Drawing with color UIDeviceRGBColorSpace 0 0 1 1 and stroke width 1.000000
屏幕中间会显示一个蓝色圆圈。
[UIUColor blackColor]
,
[UIColor grayColor]
, 或
[UIColor whiteColor]
(但随后也更改了 View 的
backgroundColor
),不再显示圆圈。
最佳答案
黑色、白色和灰色(由您命名的方法返回)不在 RGB 颜色空间中。它们位于灰度色彩空间中。灰度色彩空间只有一个分量(加上 alpha),而不是三个(加上 alpha)。所以你只设置了描边颜色的一个组件,而其他两个组件是未定义的。由于这个问题,您可能最终将 alpha 设置为零,因此您什么也得不到。
不要使用 CGContextSetStrokeColor
.它要求您担心色彩空间(您需要使用 CGContextSetStrokeColorSpace
进行设置)。相反,请使用 CGContextSetStrokeColorWithColor
,它设置颜色空间和颜色分量:
CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
关于iOS - Core Graphics 适用于颜色,但不适用于黑色、白色、灰色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24218136/
我想将灰度化的 iplimage 转换为 uiimage,反之亦然。我有如下两种方法在 RGB 色彩空间转换中成功,但对于灰色图像没有成功。 - (UIImage *)UIImageFromIplIm
我有一个服务器/客户端应用程序。服务器为每个客户端都有按钮。连接客户端后,按钮将变为启用状态,您可以单击该按钮。单击该按钮时,会出现一个新窗口,显示该特定客户端的信息,如 IP 地址、端口号等。 现在
在我的代理模型中,基础 QSortFilterProxyModel 在 flags 中虚方法: Qt::ItemFlags File_List_Proxy::flags(const QModelInd
我正在尝试重新创建此 UISearchBar(如表搜索示例代码中所示): alt text http://img168.imageshack.us/img168/6378/43558113.png 我
我正在尝试突出显示页面其余部分的 div/灰色。我的代码是: jQuery(document).ready(function ($) { $('.entry-content').mouseover(f
编辑2:如果我尝试将 JLabel 添加到复选框所在的区域(您在第二张图片中看到),我也会得到一个白色/灰色区域。 编辑:另请注意:当我刚刚创建 JLabel 并在将 TotalResultArea
我使用的是 Xcode 5.1.1,部署到 SDK 7.1。出于某种原因,当我添加一个选项卡栏 Controller 时,底部的项目没有显示,所有底部栏都是灰色的,关联的 View Controlle
我在对话框中嵌入了一个无模式属性表。我没有为控件使用新的窗口类,但确实使属性表成为对话框中容器的子项。除了一件事,一切都很好。当用户点击属性表时,对话框的标题栏由蓝色(ACTIVE)变为灰色(INAC
我正在修改别人的代码。他们使用通过 BufferedImage 加载的 PNG。我需要加载一个 TGA,它只是一个 18 字节的 header 和 BGR 代码。我加载并运行了纹理,但我得到的是灰色框
有没有办法让 html 单选列表输入“变灰”?我知道我实际上可以改变颜色..但我想做到这一点,所以单选按钮列表也不能切换。我还希望它在此状态下“突出显示”或切换到特定的 radio 列表。 例如,对于
我有一个叠加层并在滚动条仍然可见时禁用滚动(变灰),我使用了: CSS html.noscroll { position: fixed; overflow-y: scroll;
我最近重命名了我的项目,并且出现了与 Xcode 试图用来访问我的文件的路径相关的各种错误。 这很可能是由于重命名项目的错误尝试,所以我收回了努力,决定只更改客户看到的应用程序的名称。无论如何,一个特
我已将项目的 minSdkVersion 设置为 19 并启用了 Instant Run 。我已经在运行 API 21 的设备上部署了该应用程序,但是“应用更改”按钮显示为灰色。当我将鼠标悬停在该按钮
我使用以下方法在我的 Cocoa 应用程序中加载自定义文件导入窗口: [NSApp runModalForWindow:window]; 窗口显示得很好,并且是模态的。 但是,应用程序主菜单仍然处于事
我似乎无法向模拟器添加任何模拟位置,因为相应的菜单已完全变灰,如图所示: 使用实际设备进行调试时,该位置效果很好。 任何想法? 最佳答案 必须先运行iOS模拟器,然后才能启用该菜单。对我来说,它在成功
每当自动布局约束从尺寸检查器中“删除”时,它实际上并没有被删除,而只是“卸载”。在这一点之后,它仍然存在,只是褪色/变灰,在左侧的场景层次结构中可见,当在尺寸检查器的约束下选择“全部”时。 场景层次:
我正在尝试拍摄照片,然后允许用户添加一些效果、绘图、将其他 Assets 拖到图像、添加文本等。就像 snapchat 相机。 我已经关注了 Camera 2 API sample .代码的主要部分位
我正在使用 Google map 在我的网站上显示很多兴趣点,但它实际上不起作用。最奇怪的是,在实践中,它之所以有效,是因为标记和集群工作正常,连接的 Action 也在工作,但 map 没有显示,
我在使用 Fotorama 4 时遇到了一些显示问题,我不知道如何解决它。 当我在 codepen.io 中预览代码时,它看起来不错,但是当我将它放入我正在为客户工作的 wix 网站时,一些缩略图只是
我不知道如何使 Tkinter Checkbutton 变灰。 我尝试使用 state=DISABLED 但它不起作用,我收到一条错误提示 _tkinter.TclError: bad option
我是一名优秀的程序员,十分优秀!