Latest 1.0.3
Homepage https://github.com/ApterKing/AKExtensions
License MIT
Platforms ios 9.0, requires ARC
Frameworks Foundation, UIKit, CoreGraphics
Authors

Swift 常用Extension

Usage:

  • 通过pod 方式引入

pod 'AKExtensions'

  • 部分说明

    • UIDevice+Extension
      判定设备类型,设备是否为尺寸
    • UIColor+Extension
      将16进制转换为UIColor

      // 通过Int 转换为Color
      let color0 = UIColor(numberColor: 0xFF00FF)
      let color1 = UIColor(numberColor: 0xFF00FF, alpha: 0.4)
      
      // 通过hex # 转换为Color
      let color2 = UIColor(hexColor: "#FF00FF", alpha: 0.8)
      
      // 通过hex 0x或者0X 转换为Color
      let color3 = UIColor(hexColor: "0xFF00FF", alpha: 0.8)
      let color4 = UIColor(hexColor: "0XFF00FF", alpha: 0.8)
    • UIImage+Extension
      通过颜色生成UIImage

      let image = UIImage(color: UIColor.green, size: CGSize(width: 1.0, height:1.0))

      设置图片圆角

      let image = ...
      image = image.round(byRoundingCorners:UIRectCorner.allCorners, cornerRadi:15)
      // 或者
      image = image.round(byRoundingCorners:UIRectCorner.allCorners, cornerRadii:CGSize(width:15, height: 10))
      
      ...

      生成二维码

      let image = UIImage.generateQRImage(QRCodeString: "https://github.com/ApterKing/AKSwifty", logo: UIImage(named: "logo"), size: CGSize(width: 1024, height: 1024))
      let imageView = ...

    • String+Extension
      Base64转换

      let string = ...
      // Encode
      let encodedString = string.base64EncodedString()
      
      // Decode
      let decodedString = encodedString.base64DecodedString()
      
      // 计算String size
      let size = string.size(with: UIFont.systemFont(ofSize: 20), toSize: CGSize(width: 100, height: 100))
    • UIView+Extension
      获取所在UIViewController

      let view = ...
      let viewController = view.firstViewController

      Frame获取及设置

      let view = ...
      view.x = 10
      view.y = 10
      view.height = 300
      view.width = 300
      view.top = 30
      view.left = 30
      view.bottom = 50
      view.right = 50

      将UIView设置圆角

      let view = ...
      
      let cornerv1 = UIRectCorner.topLeft.rawValue | UIRectCorner.bottomRight.rawValue
      view.round(byRoundingCorners: UIRectCorner(rawValue: cornerv1), cornerRadi: 45)
      
      let cornerv2 = UIRectCorner.topRight.rawValue | UIRectCorner.bottomLeft.rawValue | UIRectCorner.bottomRight.rawValue
      view.round(byRoundingCorners: UIRectCorner(rawValue: cornerv2), cornerRadii: CGSize(width: 45, height: 45))

      。。。还有更多你可以查看源码试着使用

Author

ApterKing, [email protected]

License

AKExtensions is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "AKExtensions",
    "version": "1.0.3",
    "summary": "The Commonly Used Swfit Extension",
    "homepage": "https://github.com/ApterKing/AKExtensions",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "ApterKing": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/ApterKing/AKExtensions.git",
        "tag": "1.0.3"
    },
    "source_files": "Pod/Classes/**/*.swift",
    "frameworks": [
        "Foundation",
        "UIKit",
        "CoreGraphics"
    ],
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This