WGQRadioGroup 0.3.3

WGQRadioGroup 0.3.3

disburden维护。




  • disburden

WGQRadioGroup

使用超方便的单选组

要求

  • iOS 9+

示例

demo列表

安装

CocoaPods

使用wheel框架!pod 'WGQRaidoGroup'

手动拖入

将 WGQRaidoGroup 文件夹拖入项目中即可使用

如何使用

        var baseInfo = RadioBaseInfo();
        baseInfo.normalImage = baseInfo.normalImage.reSizeImage(reSize: CGSize(width: imageSideLength, height: imageSideLength));
        baseInfo.selectImage = baseInfo.selectImage.reSizeImage(reSize: CGSize(width: imageSideLength, height: imageSideLength));
        
        //添加音乐输入模式单选组
        let inputRadioOptions = ["VOD","BGM","OPT"];
        inputRadioGroup = WGQRadioGroup(baseInfomation: baseInfo, options: inputRadioOptions,columnCount:1, delegate: self);
        if let radioGroup = inputRadioGroup
        {
            self.view.addSubview(radioGroup);
            radioGroup.translatesAutoresizingMaskIntoConstraints = false;
        }
        
        //添加布局
        let metrics = ["inputH":150,
                       "inputW":91,
                       ...]
 
        let bindings = ["inputRadioGroup":inputRadioGroup!,"effectRadioGroup":effectRadioGroup!];  
        var constraints = [NSLayoutConstraint]();  
        
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-100-[inputRadioGroup(inputH)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: bindings);
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "H:|-42-[inputRadioGroup(inputW)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: bindings);
        constraints += .....
                       
                       

代理方法

extension ViewController:WGQRadioGroupProtocol {
    func valueDidChange(radioGroup: WGQRadioGroup, newIndex: Int) {
        if radioGroup == inputRadioGroup {
            print("更换音乐输入模式为:\(newIndex)")
        }
        
        if radioGroup == effectRadioGroup {
            print("更换效果模式为:\(newIndex)")
        }
    }
}

下一个

约束按钮的image为正方形

联系我

许可证

WGQRaidoGroup 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE