- iOS 9+
use_frameworks! 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为正方形
- Email: [email protected]
- blog: http://blog.wgq.name
WGQRaidoGroup is available under the MIT license. See the LICENSE for more info.