Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 1.37 KB

README.md

File metadata and controls

39 lines (23 loc) · 1.37 KB

CircleBlur

Image of proper labels

A modified take on the iMessage/Contacts App style of putting initials in a circle. This one uses UIVibrancyEffect and UIBlurEffect instead of a custom drawRect.

Note

This ONLY works on multicolored backgrounds.

Setup

CNBlurredAbbreviatedLabel *label = [[CNBlurredAbbreviatedLabel alloc] initWithFrame: frame];

// Optional properties
// label.color = [UIColor blueColor];
// label.colorAlpha = 0.5;
// label.labelRadiusFactor = 2.01;

[view addSubView: label];

Alternatively, simply drop a UIView into a storyboard VC and set it's class in the Identity inspector to CNBlurredAbbreviatedLabel.

Bug

Setting property labelRadiusFactor which is the the base View's layer.cornerRadius property to 2.0, which calculates the bounds.size.width/2.0, causes UIBlurEffect to not function properly. Why?

ANSWER: Because the docs for UIVisualEffectView clearly state that changing the alpha of the same will result in undefined behaviour. Removing the call to

blurView.backgroundColor = [self.color colorWithAlphaComponent:self.colorAlpha];

fixes the issue even when labelRadiusFactor is 2.0. To get the desired effect, change the backgroundColor property of the contentView.