iOS 制作基于pod开发第三方framework的二次封装
主要记录如何将第三方SDK的.a或framwwork集成到自己的framework中,并构建自己的pod发布到私有库所遇到的问题。
集成
| import IGListKit | |
| public protocol Diffable: Equatable { | |
| var diffIdentifier: String { get } | |
| } | |
| final class DiffableBox<T: Diffable>: ListDiffable { | |
| let value: T | |
| let identifier: NSObjectProtocol |
| 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) |
| // | |
| // 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. |
| // | |
| // WatchSessionManager.swift | |
| // WatchConnectivityDemo | |
| // | |
| // Created by Natasha Murashev on 9/3/15. | |
| // Copyright © 2015 NatashaTheRobot. All rights reserved. | |
| // | |
| import WatchConnectivity |
| import UIKit | |
| import CoreBluetooth | |
| import RxSwift | |
| import RxBluetoothKit | |
| extension CBUUID { | |
| var type: UUID { | |
| return UUID(rawValue: uuidString)! | |
| } | |
| 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 } | |
| } | |
| // 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) |
@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);
- (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];