import UIKit
class UpdateUsersManagmentViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func checkBoxTapped(_ sender:UIButton) {
UIView.animate(withDuration: 0.5, delay: 0.1, options: .curveLinear, animations: {
sender.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
}) { (success) in
sender.isSelected = !sender.isSelected
UIView.animate(withDuration: 0.5, delay: 0.1, options: .curveLinear, animations: {
sender.transform = .identity
}, completion: nil)
}
}
}
答案 0 :(得分:0)
我将有一个方法可以做到这一点。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#76d273" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#76d63f" />
</shape>
</item>
<item
android:bottom="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="#d63f60" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
另一个选择是这样的:
android:background="@drawable/test_drawable"
答案 1 :(得分:0)
如果要从组中选择一个选项,最好使用单选按钮而不是复选框。
如果没有,我们应该手动进行。我迅速完成了工作
@objc func selector(_ sender: NSButton)
{
if sender == checkBox1
{
if sender.state == .on && checkBox2.state == .on
{
checkBox2.state = .off
}
}
if sender == checkBox2
{
if sender.state == .on && checkBox1.state == .on
{
checkBox1.state = .off
}
}
}