Skip to content

Instantly share code, notes, and snippets.

View liuzhida33's full-sized avatar

Holiday liuzhida33

  • Joylife
  • Beijing China
View GitHub Profile
@liuzhida33
liuzhida33 / ChangePicColor.md
Last active July 12, 2018 05:18
iOS修改图片颜色
- (UIImage *)imageWithColor:(UIColor *)color{
    UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, 0, self.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);
    CGContextSetBlendMode(context, kCGBlendModeNormal);
    CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
    CGContextClipToMask(context, rect, self.CGImage);
 [color setFill];
@liuzhida33
liuzhida33 / UIScrollView+MJ_Header_Swizzed.md
Created July 31, 2018 10:07
hook mj_header 添加下拉刷新震动
@implementation UIScrollView (Swizz)

+ (void)load {
    
    SEL originalSelector = @selector(setMj_header:);
    SEL swizzledSelector = @selector(nr_setMj_header:);
    Method originalMethod = class_getInstanceMethod(self.class, originalSelector);
    Method swizzledMethod = class_getInstanceMethod(self.class, swizzledSelector);
    
@liuzhida33
liuzhida33 / UIImageExtension.swift
Last active October 23, 2018 06:23
swift UIImageExtension
// MARK: 颜色转UIImage
extension UIImage {
public convenience init?(color: UIColor, size: CGSize = CGSize(width: 1.0, height: 1.0)) {
UIGraphicsBeginImageContextWithOptions(size, true, UIScreen.main.scale)
defer {
UIGraphicsEndImageContext()
}
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(color.cgColor)
@liuzhida33
liuzhida33 / WKWebview+RxSwift.swift
Created November 12, 2018 04:35
WKWebview 添加loading和estimatedProgress rx属性
extension Reactive where Base: WKWebView {
var loading: Observable<Bool> {
return observeWeakly(Bool.self, "loading", options: [.initial, .new]).map { $0 ?? false }
}
var estimatedProgress: Observable<Double> {
return observeWeakly(Double.self, "estimatedProgress").map { $0 ?? 0 }
}
@liuzhida33
liuzhida33 / 20181202.md
Last active March 26, 2021 09:28
iOS 制作基于pod开发第三方framework的二次封装

iOS 制作基于pod开发第三方framework的二次封装

主要记录如何将第三方SDK的.a或framwwork集成到自己的framework中,并构建自己的pod发布到私有库所遇到的问题。

集成

  1. 打开第三方SDK找到二进制文件(以iflyMSC.framework为例)
  2. 将iflyMSC的二进制文件改成.a的后缀名,重命名为libiflyMSC.a。 如果不加lib前缀,那么在后面进行pod lib lint命令时有可能会遇到这样的错误提示:
@liuzhida33
liuzhida33 / ViewController.swift
Created December 20, 2018 05:53 — forked from huguesbr/ViewController.swift
Sample RxBluetoothKit implementation
import UIKit
import CoreBluetooth
import RxSwift
import RxBluetoothKit
extension CBUUID {
var type: UUID {
return UUID(rawValue: uuidString)!
}
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright © 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity
@liuzhida33
liuzhida33 / Badge.swift
Created July 2, 2019 01:46 — forked from yonat/Badge.swift
Rounded UILabel and UIButton, Badged UIBarButtonItem
//
// Badge.swift
// Extensions for Rounded UILabel and UIButton, Badged UIBarButtonItem.
//
// Usage:
// let label = UILabel(badgeText: "Rounded Label");
// let button = UIButton(type: .System); button.rounded = true
// let barButton = UIBarButtonItem(badge: "42", title: "How Many Roads", target: self, action: "answer")
//
// Created by Yonat Sharon on 06.04.2015.
@liuzhida33
liuzhida33 / TextSize.swift
Created August 19, 2019 03:54 — forked from gnou/TextSize.swift
Calculate height of some text when width is fixed
public struct TextSize {
fileprivate struct CacheEntry: Hashable {
let text: String
let font: UIFont
let width: CGFloat
let insets: UIEdgeInsets
fileprivate var hashValue: Int {
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right)
@liuzhida33
liuzhida33 / Diffable.swift
Created September 2, 2019 01:07
IGListKit Extension
import IGListKit
public protocol Diffable: Equatable {
var diffIdentifier: String { get }
}
final class DiffableBox<T: Diffable>: ListDiffable {
let value: T
let identifier: NSObjectProtocol