简体   繁体   English

iOS 中的辉光或太阳光效果

[英]Glow or Sun light effect in iOS

I need Glow or Sun light effect on my UIViewController(Some thing like this : http://www.thewhitegoddess.co.uk/the_elements/the_planets/images/sun.jpg ).我的 UIViewController 需要辉光或太阳光效果(类似这样的东西: http : //www.thewhitegoddess.co.uk/the_elements/the_planets/images/sun.jpg )。

I try this https://github.com/thesecretlab/UIView-Glow ( http://www.secretlab.com.au/blog/2012/06/23/glowing ) and drop shadow effect on layer but both when I increase the size of effect it not working.我试试这个https://github.com/thesecretlab/UIView-Glow ( http://www.secretlab.com.au/blog/2012/06/23/glowing ) 并在图层上放置阴影效果但是当我增加时它不起作用的效果大小。

please guide me and provide solution.请指导我并提供解决方案。 Thank in advance.预先感谢。

Here is an example of glow that you could use, you need to mix a bit with the colors and the glow, but it´sa start for you.这是您可以使用的发光示例,您需要将颜色和发光混合一点,但这对您来说是一个开始。 I have also included a animation example if you need it:如果您需要,我还提供了一个动画示例:

With animation:带动画:

func makeViewShine(view: UIView) {
    view.layer.shadowColor = UIColor.yellow.cgColor
    view.layer.shadowRadius = 10.0
    view.layer.shadowOpacity = 1.0
    view.layer.shadowOffset = .zero
    UIView.animate(withDuration: 0.7, delay: 0, options: [.autoreverse, .curveEaseInOut, .repeat, .allowUserInteraction], animations: {() -> Void in
        view.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
        }, completion: {(finished: Bool) -> Void in
            view.layer.shadowRadius = 0.0
            view.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
    })
}

Without animation:没有动画:

func makeViewShine(view: UIView) {
    view.layer.shadowColor = UIColor.yellow.cgColor
    view.layer.shadowRadius = 10.0
    view.layer.shadowOpacity = 1.0
    view.layer.shadowOffset = .zero
}

To use it, simply call the method and pass the view.要使用它,只需调用该方法并传递视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM