开发周报 12月 - 1

2016-12-09  本文已影响89人  奇董

1.UIView 封装的动画Transition

UIView层 对于transition 的翻转动画有2种

open class func transition(from fromView: UIView, to toView: UIView, duration: TimeInterval, options: UIViewAnimationOptions = [], completion: (@escaping (Bool) -> Swift.Void)? = nil)

这个是2个view 之间的翻转动画

open class func transition(with view: UIView, duration: TimeInterval, options: UIViewAnimationOptions = [], animations: (@escaping () -> Swift.Void)?, completion: (@escaping (Bool) -> Swift.Void)? = nil)

这是单个页面的翻转动画 可用于imageView的重新赋值,新老图片转换有翻转效果*****标记一下

2.Toolbar

NavigationC 中自带toolbar

3.Stroyboard

3.1在sb中可以拖拽预留的控件


![934EB4FA-C154-496C-BB03-D00B5F00875D.png](https://img.haomeiwen.com/i1106106/91e1670342ab9483.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

这样就可以在sb中初始化 但不展示在sb的VC中
这种方式 在toolbar切换item中格外好用

3.2 Embed Segue
如果在sb中实现parent child VC? sb中其实有一个contain view 的控件就可以实现父子VC的关系。连接的Segue 为embed segue

4.Progress

第一个接触这个是在AFN中,苹果单独将下载任务抽象成一个类
progress在处理多任务 和 父子任务 特别方便

open var totalUnitCount: Int64 //任务总量
 open var completedUnitCount: Int64//完成的任务数
open var localizedDescription: String!//完成任务数的描述 -
open var localizedAdditionalDescription: String!
open var isCancellable: Bool //是否可取消
open var isPausable: Bool // 是否可暂停
以及对应的处理
open var cancellationHandler: (() -> Swift.Void)?
open var pausingHandler: (() -> Swift.Void)?

//==
open var fractionCompleted: Double { get }//一半通过kvo来监听属性来获取进度

在子线程中进行下载任务的话,可以绑定子线程

open func becomeCurrent(withPendingUnitCount unitCount: Int64)//绑定
在其中初始化的progress 默认子progress
open func resignCurrent()//解绑

父子progress还有其他方法

@available(iOS 9.0, *)
public /*not inherited*/ init(totalUnitCount unitCount: Int64, parent: Progress, pendingUnitCount portionOfParentTotalUnitCount: Int64)

public init(parent parentProgressOrNil: Progress?, userInfo userInfoOrNil: [AnyHashable : Any]? = nil)

@available(iOS 9.0, *)
    open func addChild(_ child: Progress, withPendingUnitCount inUnitCount: Int64)

5.dispatch 定时器

DispatchSourceTimer协议
DispatchSource类遵循上面Timer协议

//初始化
public class func makeTimerSource(flags: DispatchSource.TimerFlags = default, queue: DispatchQueue? = default) -> DispatchSourceTimer
//开始
public func scheduleRepeating(deadline: DispatchTime, interval: DispatchTimeInterval, leeway: DispatchTimeInterval = default)

之后可以可以对应的取消暂停 都有对应的闭包操作

6.coreImage

CIImage     //coreImage的处理单元
CIFilter      //图片处理类
CIContext // 渲染
顺序是
1 CIImage kvc 给CIFilter的“inputImage” 选择滤镜效果
2CIContext 根据CIFIlter的outputImage 渲染出最后的cgimage

var outputImage: UIImage?
        
if let filter = CIFilter(name: "CIPhotoEffectTransfer"), let cgImage = image.cgImage {
            let filterInput = CIImage(cgImage: cgImage)
            
            filter.setValue(filterInput, forKey: "inputImage")
            
            guard let filterOutput = filter.outputImage else { return outputImage }
            
            let context = CIContext(options: [:])
            let outputCGImage = context.createCGImage(filterOutput, from: filterOutput.extent)

            outputImage = UIImage(cgImage: outputCGImage!)
        }

http://blog.csdn.net/miracle_of_thinking/article/details/8141051

上一篇下一篇

猜你喜欢

热点阅读