LK__
LK__

Reputation: 6713

Implement Blur over parts of view

How can I implement the image below pragmatically - meaning the digits can change at runtime or even be replaced with a movie?

enter image description here

Upvotes: 0

Views: 1241

Answers (3)

Matic Oblak
Matic Oblak

Reputation: 16774

This is generally the same question and is answered by quite a few methods.. Anyway I would propose 1 more:

Get the image from UIView

+ (UIImage *)imageFromLayer:(CALayer *)layer {
    UIGraphicsBeginImageContext([layer frame].size);
    [layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return outputImage;
}

rather yet play around a bit with this to get the desired part of the view as the image. Now create a new view and add to it image views (with the image you get from layer). Then move the centers of the image views to achieve gaussian algorithm and take the image from this layer again and place it back on the original view.

Moving the center should be defined by radius fragment (I'd start with .5f) and resample range.

for(int i=1; i<resampleCount; i++) {
view1.center = CGPointMake(view1.center.x + radiusFragment*i, view1.center.y);
view2.center = CGPointMake(view2.center.x - radiusFragment*i, view2.center.y);
view3.center = CGPointMake(view3.center.x, view3.center.y + radiusFragment*i);
view4.center = CGPointMake(view4.center.x, view4.center.y - radiusFragment*i);
//add the subviews
}
//get the image from view

All the subviews need to have alpha set to 1.0f/(resampleCount*4)

This method might not be the fastest but it would be extremely easy to implement and if you can pimp the radius and resample range to minimum fragments it should do pretty well.

Upvotes: 1

skytz
skytz

Reputation: 2201

Just add a blurred UIView on top of your thing.

For example...make a UIImage of your desired view size, blur it using CIFilter and then add it to your view .It should achieve the desired effect.

Upvotes: 1

Bonnie
Bonnie

Reputation: 4953

use a UIView whith white background and decrease the alpha property

blurView.backgroundColor=[UIColor colorWithRed:255 green:255 blue:255 alpha:0.3]

Upvotes: -1

Related Questions