 //  Created by MrBai on 2017/5/16.
 //  Copyright © 2017年 baiqiang. All rights reserved.
 //
-
 import UIKit
 
-/// btnSubView location
-///
-/// - none: normal
-/// - left: image.origin.x == btn.origin.x, title behiand image
-/// - right: title.maxY == btn.maxY, title behiand image
-/// - imgTopTitleBottom: image(title).center.x = btn.center.x, image at top, title at bottom
 enum BtnSubViewAdjust {
     case none
     case left

        btn.setBordColor(color: UIColor.mainColor)
        return btn
    }
    /// 调整btn视图和文字位置()
    ///
    /// - Parameters:

        var imageTop: CGFloat = 0
        var titleLeft: CGFloat = 0
        var titleTop: CGFloat = 0
        var titleRift: CGFloat = 0
        if type == .imgTopTitleBottom {
            imageLeft = (width - imgView.frame.width) * 0.5 - imgView.frame.origin.x
            imageTop = spacing - imgView.frame.origin.y
            titleLeft = (width - titleLab.frame.width) * 0.5 - titleLab.frame.origin.x - titleLab.frame.origin.x
            titleTop = spacing * 2 + imgView.frame.height - titleLab.frame.origin.y
            titleRift = -titleLeft - titleLab.frame.origin.x * 2
        }else if type == .left {
            imageLeft = spacing - imgView.frame.origin.x
            titleLeft = spacing * 2 + imgView.frame.width - titleLab.frame.origin.x
            titleRift = -titleLeft
        }else {
            titleLeft = width - titleLab.frame.maxX - spacing
            titleRift = -titleLeft
            imageLeft = width - imgView.right - spacing * 2 - titleLab.frame.width
        }
        self.imageEdgeInsets = UIEdgeInsetsMake(imageTop, imageLeft, -imageTop, -imageLeft)
        self.titleEdgeInsets = UIEdgeInsetsMake(titleTop, titleLeft, -titleTop, titleRift)
    }
}
