Latest 1.0.0
Homepage https://github.com/Xiaoye220/YFTools
License MIT
Platforms ios 8.0
Authors

一些类的拓展,方便这些类的使用

v1.0.0

1. UIImage:

  • 拓展截屏
  • 缩放图片到指定尺寸
  • 将原图缩放到整个屏幕大小后裁剪指定rect大小的图片
  • 按较大边缩放图片
  • 将多个image横向组合成一幅image

2. UIView:

  • 直接获取、设置 frame 的 x、y、origin 和 size

3. String:

  • 利用下标截取字符串

example:

字符串 str = "abcdefg", str[0,1] = "ab", str[1, 3] = "bcd"

4. UIColor:

  • 根据 16进制 颜色代码初始化颜色

5. MBProgressHUD:

  • 可以通过链式编程的方式自定义 MBProgressHUD

example:

hudExtension = MBProgressHUD.init(view: self.view) { hud in
            hud.contentColor(UIColor.white)
                .bezelView{ bezelView in
                    bezelView.style(.solidColor)
                        .color(themeColor)
                }
                .backgroundView { backgroundView in
                    backgroundView.color(UIColor.black.withAlphaComponent(0.3))
                }
                .label { label in
                    label.text = "Extension"
                }
        }

6. RxSwift

  • 拓展 UIImagePickerController 和 UIAlertController,利用 RxSwift 实现图片选择

example:

imagePickerButton.rx.tap
            .asDriver()
            .flatMapLatest { [weak self] _ in
                return UIAlertController.rx.createWithParent(self,
                                                             cancelAction: .cancel,
                                                             actions: [.camera, .photoLibrary],
                                                             type: .actionSheet)
                    .asDriver(onErrorJustReturn: .cancel)
            }
            .flatMapLatest { [weak self] alertAction in
                return UIImagePickerController.rx.createWithParent(self) { picker in
                    switch alertAction {
                    case .camera:
                        picker.sourceType = .camera
                    case .photoLibrary:
                        picker.sourceType = .photoLibrary
                    default:
                        break
                    }
                    picker.allowsEditing = true
                    }
                    .flatMap { $0.rx.didFinishPickingMediaWithInfo }
                    .take(1)
                    .asDriver(onErrorJustReturn: [:])
            }
            .map { info in
                return info[UIImagePickerControllerEditedImage] as? UIImage
            }
            .drive(onNext: { [weak self] image in
                self?.displayPhoto.image = image
            })
            .disposed(by: disposeBag)

Latest podspec

{
    "name": "YFTools",
    "version": "1.0.0",
    "summary": "YFTools.",
    "description": "u4e00u4e9bu7c7bu7684u62d3u5c55uff0cu65b9u4fbfu4f7fu7528",
    "homepage": "https://github.com/Xiaoye220/YFTools",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Xiaoye__220": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Xiaoye220/YFTools.git",
        "tag": "v1.0.0"
    },
    "source_files": [
        "YFTools/OriginalAPI+Extension/*",
        "YFTools/Vendors+Extension/*"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This