我讨厌苹果从 Swift 3.1 到 Swift 4 的所有变化。现在我又面临另一个困境。我能够自定义搜索栏,但现在我需要更改输入文本和占位符的来源。
我已经感动了天地,但我找不到改变字体的解决方案。我还想将搜索图标更改为自定义图标。
我需要使用分段控件来更改视图.在以下示例中,我将两个视图容器放在同一位置:
第二个容器是隐藏的,每次我使用分段控件时我都会通过代码显示它.(虽然它也没有显示出来.)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var container1: UIView!
@IBOutlet weak var container2: UIView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func showComponent(_ sender: Any) {
if (sender as AnyObject).selectedSegmentIndex == 0 {
UIView.animate(withDuration: 0.5, animations: {
self.container1.alpha = 1
self.container2.alpha = 0
})
} else {
UIView.animate(withDuration: 0.5, animations: {
self.container1.alpha = 0
self.container2.alpha = 1
})
}
}
}
Run Code Online (Sandbox Code Playgroud)
你知道其他任何方法吗?
有没有办法自定义SegmentedControl,好像它是一个TAB?