zoukankan      html  css  js  c++  java
  • swift把颜色转成图片

    // 把颜色转成图片 

     

     func imageFromColor(color: UIColor, viewSize: CGSize) -> UIImage{

            let rect: CGRect = CGRect(x: 0, y: 0, viewSize.width, height: viewSize.height)

            UIGraphicsBeginImageContext(rect.size)

            let context: CGContext = UIGraphicsGetCurrentContext()!

            context.setFillColor(color.cgColor)

            context.fill(rect)

            

            let image = UIGraphicsGetImageFromCurrentImageContext()

            UIGraphicsGetCurrentContext()

            return image!

        }

     

     

    // 调用方法替换导航栏背景色

            navigationController?.navigationBar.setBackgroundImage(imageFromColor(color: UIColor.white.withAlphaComponent(0), viewSize: CGSize( kScreenW, height: 1)), for: UIBarPosition.any, barMetrics: UIBarMetrics.default)

            

            navigationController?.navigationBar.shadowImage = UIImage()

  • 相关阅读:
    移动端滑动效果
    使用Bash时的几点总结
    docker-It's possible that too few managers are online. Make sure more than half of the managers are online.
    基于elk 实现nginx日志收集与数据分析。
    python-num18 - django进阶一
    文成小盆友python-num17 - django基础
    文成小盆友python-num15 - JavaScript基础
    文成小盆友python-num14 - web 前端基础 html ,css, JavaScript
    文成小盆友python-num13 整个堡垒机
    install pip3 for python 3.x
  • 原文地址:https://www.cnblogs.com/supersr/p/6743410.html
Copyright © 2011-2022 走看看