我有一个全黑的UIImage,有一个alpha通道,所以有些部分是灰色的,有些部分是完全透明的.我希望将这些图像用作其他颜色的遮罩(让我们说白色以使其变得容易),因此最终产品现在是白色图像,其中部分透明.
但我对Quartz/Core Graphics完全不熟悉,所以我不能真正理解这些例子.
有谁知道我可以用来查看一些完整代码示例的链接?
如何通过编程改变UIImage的颜色,请帮忙吗?如果我发送UIImage,它的颜色需要改变任何帮助吗?如果我通过bitmaphandling改变RGB颜色,它就不起作用.
我试图在一些当前的UIImage(白色)上添加黑色覆盖.我一直在尝试使用以下代码:
[[UIColor blackColor] set];
[image drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeOverlay alpha:1.0];
Run Code Online (Sandbox Code Playgroud)
但它不起作用,而且我很确定套装不应该在那里.
tintColor是一个救生员,它需要应用主题到一个全新的(简单)级别.
//the life saving bit is the new UIImageRenderingModeAlwaysTemplate mode of UIImage
UIImage *templateImage = [[UIImage imageNamed:@"myTemplateImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imageView.image = templateImage;
//set the desired tintColor
imageView.tintColor = color;
Run Code Online (Sandbox Code Playgroud)
上面的代码将根据UIImageview的色调颜色"绘制"图像的非透明部分,这非常酷.不需要像这样简单的核心图形.
我面临的问题是动画.
继续上述代码:
//The array with the names of the images we want to animate
NSArray *imageNames = @[@"1",@"2"@"3"@"4"@"5"];
//The array with the actual images
NSMutableArray *images = [NSMutableArray new];
for (int i = 0; i < imageNames.count; i++)
{
[images addObject:[[UIImage imageNamed:[imageNames objectAtIndex:i]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
}
//We set the animation images of …
Run Code Online (Sandbox Code Playgroud) 我有一个图像,我想通过编程方式更改该图像的颜色.
&我想改变这一形象的颜色
我正在尝试SKSpriteNode
使用 SF Symbols 字体的图像创建一个图像,虽然我可以做到这一点,但我似乎无法将其设置为黑色以外的任何颜色。
这是我的代码:
let image = UIImage.init(systemName: "gear")
let colored = image!.withTintColor(.red)
let texture = SKTexture.init(image: colored)
let sprite = SKSpriteNode.init(texture: texture, size: CGSize.init(width: 32, height: 32))
Run Code Online (Sandbox Code Playgroud)
不幸的是,生成的精灵总是显示为黑色(而不是红色)。
我究竟做错了什么?
iphone ×3
objective-c ×3
ios ×2
animation ×1
cocoa-touch ×1
image ×1
quartz-2d ×1
sf-symbols ×1
sprite-kit ×1
swift ×1
tintcolor ×1
uicolor ×1
uiimage ×1
uiimageview ×1