Swift学习

swift-基础-一些OC与Swift的对照

2016-08-15  本文已影响19人  埃林的奶酪

枚举

public enum SVProgressHUDStyle : Int {
    
    case Light 
    case Dark 
    case Custom 
}
        UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.7, initialSpringVelocity: 5, options:
UIViewAnimationOptions.init(rawValue: 0), animations: {
            self.startButton.transform = CGAffineTransformIdentity
        }) { (_) in
            
        }
        UIRectCorner corners = UIRectCornerTopRight | UIRectCornerBottomRight | UIRectCornerBottomLeft;
        //create path
        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:radii];
        let corner = UIRectCorner.TopLeft.rawValue | UIRectCorner.TopRight.rawValue | UIRectCorner.BottomLeft.rawValue
        UIBezierPath(roundedRect: rect, byRoundingCorners: UIRectCorner(rawValue: corner), cornerRadii: size)

代理

class ComposePhotoCell: UICollectionViewCell {
    var delegate: ComposePhotoCellDelegate?
    
}

protocol ComposePhotoCellDelegate {
    func composePhotoCellAddPhotoClick(cell: ComposePhotoCell) -> Void
}
extension ViewController: UITableViewDateSource, UITableViewDelegate
{
    // 类似于OC中的分类,不能在这里定义属性
}
@objc
protocol ComposePhotoCellDelegate {
    optional func composePhotoCellAddPhotoClick(cell: ComposePhotoCell) -> Void
}

与OC的混编

QQ20160815-0.png
上一篇 下一篇

猜你喜欢

热点阅读