Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know a core graphics solution for the gradient but if you can make an image in photoshop which starts white on the right and fades to alpha on the left you could overlay that on top of the content image</p> <p>to overlay the image you would do something like </p> <pre><code>+ (UIImage*) addFadeOutToImage:(UIImage*)sourceImage { UIGraphicsBeginImageContext(sourceImage.size); [sourceImage drawAtPoint:CGPointZero]; UIImage* fadeAlphaImage = [UIImage imageNamed:@"fadedAlphaImage.png"]; CGPoint fadeOutStartPoint = CGPointMake(sourceImage.size.width - fadeAlphaImage.size.width, 0); //assumes the fade image is the same height as the source [fadeAlphaImage drawAtPoint:fadeOutStartPoint]; UIImage* fadeOutImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return fadeOutImage; } </code></pre> <p>this code adapted from <a href="https://stackoverflow.com/questions/679245/create-a-uiimage-from-two-other-uiimages-on-the-iphone">this question</a></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. 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