Я пытаюсь добавить эффект размытия на оверлей на карте. Мне действительно нужен эффект размытия по кругу на карте, метод, который я использую для этого, не так важен.
У меня есть класс, который простирается от MKCircleRenderer
, и я хотел добавить эффект размытия по карте, которую он охватывает.
Я пытался использовать метод -fillPath:inContext:
, но мое незнание по Core Graphics и Core Image привело меня в никуда, и я действительно действительно потерял эту проблему.
Моя попытка заключалась в использовании CIFilter
, и для этого мне понадобился CIImage
, который я пытался создать из контекста. Но я не нашел способа создать CGBitmapContext
, CGImage
или любой другой класс из контекста. Любой метод, который я попробовал, привел к NULL без дальнейших подробностей о том, почему. Я не могу вспомнить все, что я пробовал, поэтому мне жаль, что я ничего не сказал об этом.
В моем классе в настоящее время реализованы одни методы, которые не очень много делают:
- (instancetype)initWithOverlay:(id<MKOverlay>)overlay {
if (self = [super initWithOverlay:overlay]) {
self.strokeColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
self.fillColor = [UIColor colorWithRed:0.4 green:0.2 blue:0.2 alpha:0.1];
self.lineWidth = 1;
}
return self;
}
Альтернативой может быть использование пользовательского MKAnnotation
и добавление эффекта размытия по представлению с помощью UIVisualEffectView
. Трудная часть с этим подходом увеличивает/уменьшает размер при масштабировании.
Это должно работать на iOS 8 +
Изменить
В этом случае карта за внутренней частью круга должна быть размыта