tag:blogger.com,1999:blog-4837226565419336640.post1633068026416395687..comments2023-09-22T11:09:02.250-07:00Comments on SaveMe.txt: Dynamic view reflection using CAReplicatorLayerUnknownnoreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4837226565419336640.post-57919387739516593132011-07-08T10:13:22.232-07:002011-07-08T10:13:22.232-07:00Also not sure you need to scale the reflection in ...Also not sure you need to scale the reflection in the Y axis - Seems to break the laws of physics!camdenblokehttps://www.blogger.com/profile/09315468938044700451noreply@blogger.comtag:blogger.com,1999:blog-4837226565419336640.post-90193610470525362312011-07-08T10:10:26.635-07:002011-07-08T10:10:26.635-07:00something like this seems to work - it won't p...something like this seems to work - it won't plug directly into your code as I hacked it around a bit... The anchor/frame will need tweaking<br /><br /><br /> if (gl == nil)<br /> {<br /> // add a black gradient layer<br /> gl = [CAGradientLayer layer];<br /> CGColorRef c1 = [[UIColor colorWithRed:0 green:0 blue:0 alpha:1] CGColor];<br /> CGColorRef c2 = [[UIColor colorWithRed:0 green:0 blue:0 alpha:1] CGColor];<br /> CGColorRef c3 = [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.4] CGColor];<br /> CGColorRef c4 = [[UIColor colorWithRed:0 green:0 blue:0 alpha:0] CGColor];<br /> [gl setColors:[NSArray arrayWithObjects:(id)c1, (id)c2, (id)c3, (id)c4, nil]];<br /> <br /> [gl setLocations:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:0.5], [NSNumber numberWithFloat:0.51], [NSNumber numberWithFloat:0.65],nil]];<br /> <br /> self.layer.mask = gl;<br /> }<br /> <br /> // position the gradient layer over the replication layer 2nd instance<br /> [gl setAnchorPoint:CGPointMake(0, 0)];<br /> [gl setFrame:CGRectMake(0, 0, self.frame.size.width, h1+h1)];<br /><br />This sets the top half of the gradient to be solid - no alpha, for the top part of the image, and then fades out from half way down. for the reflection.camdenblokehttps://www.blogger.com/profile/09315468938044700451noreply@blogger.comtag:blogger.com,1999:blog-4837226565419336640.post-87296749342022060692011-07-07T12:35:54.954-07:002011-07-07T12:35:54.954-07:00c.b. - thanks for the comments - yes, the original...c.b. - thanks for the comments - yes, the original post was somewhat thrown together as I was in the midst of some other things - I've updated the code today. <br /><br />With regards to applying a gradient layer to the mask property ... I'm not really sure how that would work since there's no way to directly access a CAReplicatorLayer instance and we'd only want to apply it to the second one. Adding it to the top (like I do with the CAGradientLayer) wouldn't seem to work either since you'd be masking out the gradient layer and not what's underneath...Mikehttps://www.blogger.com/profile/13481490357150851853noreply@blogger.comtag:blogger.com,1999:blog-4837226565419336640.post-15603992495351689242011-07-07T07:53:17.927-07:002011-07-07T07:53:17.927-07:00Thanks, Interesting tutorial (Wasnt aware of CARep...Thanks, Interesting tutorial (Wasnt aware of CAReplicatorLayer), but the code seems riddled with errors? Figured it out mostly for myself, but probably needs some work!<br /><br />Might also be nicer (And more useful) if instead of a black gradient overlay mask, you apply the gradient to the mask property instead, so that you can overlay i onto any coloured/textured background.camdenblokehttps://www.blogger.com/profile/09315468938044700451noreply@blogger.com