适配ios10实践经验swift3.0升级

9 篇文章 0 订阅

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)

        }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值