objective c - How can I achieve luminescent shadows? -


enter image description here

  1. the entire mockup has shadow reminds me of philip's ambilight tvs.
  2. look @ "trailer , photos" section tiles have type of shadow.

this effect fascinating watch , i'd incorporate app.

here's i've thought:

  1. take screenshot of view , enlarge 110%
  2. place behind view.
  3. blur screenshot.
  4. apply inner white shadow.

any suggestions?

your thoughts correct, there no need apply inner shadow, it's possible add transparent insets screenshot, , when blurred, create gradient you're looking for.

the following code should job:

- (void)addluminescentshadowtoview:(uiview*)contentview {     //the bigger radius of blur     //the more spread shadow     cgfloat blurradius = 15.0f;      //in order shadow becomes transparent on edeges     //we're adding transparent insets snapshot     cgfloat insetssize = 2.0f * blurradius;      //getting superview of content view     //it's important before getting snapshot     //as during snapshot parent of content view     //might temporary changed     //superview used later insert shadow     uiview* contentviewsuperview = contentview.superview;      //code following methods sourced     //http://code.tutsplus.com/tutorials/adding-blur-effects-on-ios--cms-21488 , modified     //taking snapshot of content view     //method modified add transparent insets snapshot     uiimage* snapshot = [self takesnapshotofview: contentview withtransparentinsets: insetssize];      //applying blur snapshot     uiimage* blurredsnapshot = [self blurwithcoreimage: snapshot                                             withradius: blurradius];      //creating view displays shadow     uiimageview* shadowview = [[uiimageview alloc] initwithimage: blurredsnapshot];     shadowview.center = contentview.center;      //you control appearence of effect modifying scale , alpha     //scale not uniform prevent spreading of shadow height, shown on example     shadowview.transform = cgaffinetransformmakescale(1.05f, 0.95f);     shadowview.alpha = 1.0f;      //inserting shadow below content     [contentviewsuperview insertsubview:shadowview belowsubview:contentview]; }  - (uiimage *)takesnapshotofview:(uiview *)view withtransparentinsets:(cgfloat)insets {     //creating bitmap context     cgrect contextrect;     contextrect.origin = cgpointzero;     contextrect.size = cgsizemake(view.frame.size.width + 2.0f * insets, view.frame.size.height + 2.0f * insets);      uigraphicsbeginimagecontext(contextrect.size);     cgcontextclearrect(uigraphicsgetcurrentcontext(), contextrect);      //rendering views hierarchy context     [view drawviewhierarchyinrect:cgrectmake(insets, insets, view.frame.size.width, view.frame.size.height) afterscreenupdates:yes];      //getting result image     uiimage *image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      return image; }  - (uiimage *)blurwithcoreimage:(uiimage *)sourceimage withradius:(cgfloat)radius {     ciimage *inputimage = [ciimage imagewithcgimage:sourceimage.cgimage];      //apply gaussian blur filter     cifilter *gaussianblurfilter = [cifilter filterwithname: @"cigaussianblur"];     [gaussianblurfilter setvalue: inputimage forkey:@"inputimage"];     [gaussianblurfilter setvalue: @(radius) forkey:@"inputradius"];      cicontext *context = [cicontext contextwithoptions:nil];      //creating output uiimage     cgimageref cgimage = [context createcgimage:gaussianblurfilter.outputimage fromrect:[inputimage extent]];     uiimage* outputimage = [uiimage imagewithcgimage:cgimage scale:1.0f orientation:uiimageorientationup];      cfrelease(cgimage);      return outputimage; } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -