Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use QuartzCore to apply a mask (with gradient transparency) to the UIImageView:</p> <pre><code>UIImageView *myImageView = ["the image view"]; CAGradientLayer *l = [CAGradientLayer layer]; l.frame = myImageView.bounds; l.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:0] CGColor], (id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:1] CGColor], nil]; l.startPoint = CGPointMake(0.0, 0.0f); l.endPoint = CGPointMake(1.0f, 1.0f); //you can change the direction, obviously, this would be top to bottom fade myImageView.layer.mask = l; </code></pre> <p>To save it you can find the answer easily here on Stack Overflow, just by searching for how to save the contents of the canvas to a UIImage.</p> <p>Or Swift version as requested by @Zazu:</p> <pre><code>// Whatever you image view is, obviously not hardcoded like this let imageView = UIImageView.init(image: UIImage(named: "Image")) imageView.frame = CGRectMake(0, 0, 320, 480) self.view.addSubview(imageView) // Create the gradient layer let gradientLayer = CAGradientLayer.init() gradientLayer.frame = imageView.bounds gradientLayer.colors = [ UIColor.init(colorLiteralRed: 0, green: 0, blue: 0, alpha: 0).CGColor, UIColor.init(colorLiteralRed: 0, green: 0, blue: 0, alpha: 1).CGColor] // Whatever direction you want the fade. You can use gradientLayer.locations // to provide an array of points, with matching colors for each point, // which lets you do other than just a uniform gradient. gradientLayer.startPoint = CGPointMake(1.0, 0.0); gradientLayer.endPoint = CGPointMake(0.0, 0.0); // Use the gradient layer as the mask imageView.layer.mask = gradientLayer; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload