element6
element6

Reputation: 35

iOS Possible to set a blend mode on UILabel?

Say for example you have some text put in programmatically like this:

myLabel = [[UILabel alloc] initWithFrame:CGRectMake(33, 10, 254, 100)];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setFont:[UIFont fontWithName:@"SomeFont" size:76]];
[myLabel setTextColor:[UIColor colorWithRed:0.227451 green:0.666667 blue:1 alpha:0.9]];

Is there a way to apply a blend mode on the text? Say for example Color Dodge?

Upvotes: 2

Views: 1576

Answers (1)

Nick Lockwood
Nick Lockwood

Reputation: 40995

No, it's not possible.

If you have a fixed background, you could do this by creating a custom view subclass and implementing the drawRect method yourself and using CGContext methods to set the blend mode and draw the string.

But you can't use blending between views (except alpha blending), so this kind of blending only works if you set the background manually in the drawRect. It can't be done if your view background is transparent.

Upvotes: 1

Related Questions