如何使用alpha值在CALayer()上添加颜色?

时间:2016-12-16 11:48:59

标签: ios swift uiimageview swift3 calayer

您好我使用CALayer()制作了幻灯片代码,我希望在Brown值的图像上添加alpha颜色掩码。我的CALayer()代码如下。

   let imageLayer = CALayer()
    imageLayer.contents = image.cgImage
    imageLayer.anchorPoint = CGPoint.zero
    imageLayer.bounds = CGRect(origin: CGPoint.zero, size: optimus)
    imageLayer.position = origin
    imageView.layer.addSublayer(imageLayer)

您可以在此处看到完整代码; https://github.com/Gatada/JBKenBurnsView/blob/master/KenBurns/JBKenBurnsView.swift

之间的281-286行

谢谢!

1 个答案:

答案 0 :(得分:1)

试试这样。

Sub previousslide()
With ActivePresentation.SlideShowWindow.View
    .Slide.SlideShowTransition.EntryEffect = ppEffectPushRight
    .GotoSlide (ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1)
    .Slide.SlideShowTransition.EntryEffect = ppEffectPushLeft
End Sub

修改:在您的修改代码中,您需要像这样设置imageLayer.backgroundColor = UIColor.brown.withAlphaComponent(0.8).cgColor //Set alpha you want 框架。

imageLayer2