Tag: uicolor

访问系统。具有破坏性的红色button颜色

如何访问用于破坏性警报button样式的系统红色? 例如,用于button的默认样式蓝色可以通过let systemBlueColor = view.tintColor (对应于UIColor(red: 0, green: 122, blue: 255, alpha: 1.0)在Swift中访问。 破坏性的红色似乎是由UIColor(red: 255, green: 59, blue: 48, alpha: 1.0)但有什么办法以类似的方式访问它的默认view.tintColor方法? 我已经读过RGB解释可以在设备/操作系统上有所不同,所以我想访问设备/操作系统的独立版本的颜色。

UITableViewCell内容视图 – 添加UILabels

我目前有我的UITableView我的cellForRowAtIndexPath下面的代码: – (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* CellIdentifier = @"Cell"; UILabel* nameLabel = nil; UILabel* valueLabel = nil; UILabel *percentLabel = nil; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; if ( cell == nil ) { inthere = YES; cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; nameLabel = […]

在iOS中设置两种不同颜色的button标题

我想用两种颜色在Button上设置标题。 它可能与下面给出的图像相同吗? 任何帮助将不胜感激。 提前致谢。

从一个UIColor手动颜色渐变到另一个

我试图在drawRect淡入一个UIColor到另一个UIColor 。 我创build了这个函数来计算一定比例的颜色: – (UIColor *)colorFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor percent:(float)percent { float dec = percent / 100.f; CGFloat fRed, fBlue, fGreen, fAlpha; CGFloat tRed, tBlue, tGreen, tAlpha; CGFloat red, green, blue, alpha; if(CGColorGetNumberOfComponents(fromColor.CGColor) == 2) { [fromColor getWhite:&fRed alpha:&fAlpha]; fGreen = fRed; fBlue = fRed; } else { [fromColor getRed:&fRed green:&fGreen blue:&fBlue alpha:&fAlpha]; } if(CGColorGetNumberOfComponents(toColor.CGColor) […]

使用单例创build一个基本的样式助手类

我是Objective-C的新手,我有一个build筑或devise模式的问题。 我正在构build一个iOS应用程序,并像大多数iOS应用程序,它使用各种颜色,字体,模式等。也许我目前正在写代码不正确,但我发现自己重写像颜色设置的东西。 结果,改变颜色就变成了寻找代码中的所有颜色设置,重写它们等等的运动。对我来说似乎有点低效。 例如,我在我的应用程序的多个地方使用深红色。 我倾向于频繁地写[UIColor colorWithRed …]方法。 但是,我很好奇,如果创build一个返回我自定义颜色(作为UIColor)的单例是一种合理的方法来“模块化我的风格包”。 所以我可以写这样的东西 [label setTextColor:[[MyStyleSingletonClass sharedStyler] myDarkRed]]; 因此,如果devise师突然想让myDarkRed变得更暗一点,我就改一次,穿过应用程序是很好的。 显然,风格和用户体验比颜色更多,但是我很好奇这种方法是否合理,或者如果我将来会为自己的问题设置自己的话。 或者,也许这种能力已经存在于objective-c中,而我错过了这一点。 提前致谢。

iOS Sprite Kit为什么我不能使用白色重复colorizeWithColor?

我正在尝试使用非缩放方法select精灵节点的方法。 我最喜欢的一种方法是用白色着色,从而突出显示节点。 但是,我似乎无法多次使用白色行为复制着色。 为什么我不能多次使用白色使用colorizeWithColor ? 这两个方法调用是相同的,除了使用的颜色。 如果我使用红色,灰色等,节点响应每次触摸闪烁。 但是,如果我使用白色,它只有一次,那么再也没有响应过。 [self runAction:[SKAction colorizeWithColor:[SKColor lightGrayColor] colorBlendFactor:0.8 duration:0.6] completion:^{ [self runAction:[SKAction colorizeWithColorBlendFactor:0.0 duration:0.4]]; }]; [self runAction:[SKAction colorizeWithColor:[UIColor colorWithWhite:0.99 alpha:1.0] colorBlendFactor:0.8 duration:0.6] completion:^{ [self runAction:[SKAction colorizeWithColorBlendFactor:0.0 duration:0.4]]; }];

比较UIColors或CGColor或CGColorSpace

我有一个比较UIColors的问题。 我有一个图像,我已经成功地提取用户点击图像上的颜色。 现在我想比较这种颜色与其他颜色,但我得到了一些奇怪的结果。 以下是我所尝试的: CGColorRef pixelColor = [[buttonImage colorAtPixel:point] CGColor]; UIColor* color = [UIColor colorWithCGColor:pixelColor]; UIColor* aqua = [UIColor colorWithRed:0.521569 green:0.768627 blue:0.254902 alpha:1]; if (CGColorEqualToColor(color.CGColor, aqua.CGColor)) { DLog(@"Apparently, it works"); } DLog(@"%@", color.CGColor); DLog(@"%@", aqua.CGColor); 输出: 2011-05-21 19:48:27.144 Coffee[66860:207] -[DescriptorsViewController touchesEnded:withEvent:] <CGColor 0x4d1eb80> [<CGColorSpace 0x4d1a070> (kCGColorSpaceDeviceRGB)] ( 0.521569 0.768627 0.254902 1 ) 2011-05-21 19:48:27.145 Coffee[66860:207] […]

如何在CGGradient中舒服地使用NSArray中的CGColor

我有两个UIColor实例,并希望使用它们创build一个渐变。 该代码的作品,但它给了我一个警告,当我调用arrayWithObject:构造函数: 警告:语义问题:将'CGColorRef'(又名'struct CGColor *')发送到types为“id”的参数的指针types不兼容 我怀疑有潜在的其他问题有关的警告(例如泄漏)。 这里是片段: UIColor *startColor, *endColor; // … NSArray *colors = [NSArray arrayWithObjects: startColor.CGColor, endColor.CGColor, nil]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef) colors, NULL); 如何重写代码以安全的方式摆脱这个警告? 我试图手动创build一个CGArrayRef,但一段时间后,有点讨厌。 CGGradientCreateWithColorComponents的作品,但我不喜欢手动合并所有的颜色组件到一个CGFloat components[]

在UIView的-drawRect:方法中绘制彩色文本

我想在我的UIView子类中绘制彩色的文字。 现在我正在使用Single View应用程序模板(用于testing)。 除了drawRect:方法之外,没有任何修改。 文本被绘制出来,但是无论我设置什么颜色,它总是黑色的。 – (void)drawRect:(CGRect)rect { UIFont* font = [UIFont fontWithName:@"Arial" size:72]; UIColor* textColor = [UIColor redColor]; NSDictionary* stringAttrs = @{ UITextAttributeFont : font, UITextAttributeTextColor : textColor }; NSAttributedString* attrStr = [[NSAttributedString alloc] initWithString:@"Hello" attributes:stringAttrs]; [attrStr drawAtPoint:CGPointMake(10.f, 10.f)]; } 我也试过[[UIColor redColor] set]无济于事。 回答: NSDictionary * stringAttrs = @ {NSFontAttributeName:font,NSForegroundColorAttributeName:textColor};

基于进度值的UIColor转换

我有一个ProgressBar我要分配一个customColor颜色,并基于进展淡入到另一种颜色。 使用下面的方法,我得到一个黑暗的彩虹效果颜色,包括红色,深褐色和深绿色。 起始颜色将是浅蓝色,目标颜色是浅绿色。 -(UIColor *) makeCustomColorFromProgressValue:(float) progress{ UIColor *color; // startColor Color – lightBlue float red = 0.53; float green = 0.82; float blue = 1; //Destination Color – lightGreen float finalRed = 0.53; float finalGreen = 1; float finalBlue = 0.82; float newRed = 80;//finalRed *255; float newGreen = (finalGreen *progress) *255; float newBlue […]