swift语法:
1.UIColor.white
-->UIColor.whiteColor()
focusButton.setTitleColor(UIColor.white, for: UIControlState())
2. label.font = UIFont.systemFontOfSize(12)
-->label.font = UIFont.systemFont(ofSize: 12)
if self.childViewControllers.last?.isKindOfClass(DKPersonalLiveViewController) == true
--> if self .childViewControllers.last?.isKind(of: DKPersonalLiveViewController. self )if ((self.delegate?.respondsToSelector(Selector("tipViewDidClickContinue"))) != false)
--> if (( self .delegate?.responds(to: Selector( "tipViewDidClickContinue" ))) != false )
3. layer.frame = CGRectMake(0, 0, self.frame.width, self.backImageView.frame.height)
--> layer.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.backImageView.frame.height)
4. label.textAlignment = NSTextAlignment.Center
--> label.textAlignment = NSTextAlignment.center
5.private
-->fileprivate
6.private lazy var hvClearColor: CGColor = {
return UIColor(red: 0, green: 0, blue: 0, alpha: 0.0).CGColor
}()
-->
fileprivate lazy var hvClearColor: CGColor = {
return UIColor(red: 0, green: 0, blue: 0, alpha: 0.0).cgColor
}()
7.ID
-->id(OC语法中,id是范型,不能用id作为变量。所以,swift中的变量都是小写)
8.函数参数如果没有函数名,则,前面需要加横线“_”:
class func widthFromNum(upNum:Int , fontsize:Float) -> CGFloat
--> class func widthFromNum(_ upNum:Int , fontsize:Float) -> CGFloat
9.CGRectGetMaxX(headImageView.frame)
-> headImageView.frame.maxX
10.
typealias SendIndexClosure=(indexPath:NSIndexPath,direction:UICollectionViewScrollDirection)->Void
-->
typealias SendIndexClosure=(_ indexPath:IndexPath,_ direction:UICollectionViewScrollDirection)->Void
11.
dispatch_async(dispatch_get_main_queue(), {
self.beginLoading()
})
->
DispatchQueue.main.async(execute: {
self.beginLoading()
})
dispatch_source_cancel(source!)
-> source!.cancel()
dispatch_async(dispatch_get_main_queue()) {
self.dismissViewControllerAnimated(true, completion: nil)
}
->
DispatchQueue.main.async {
self.dismiss(animated: true, completion: nil)
}