如何在iOS中实现水平进度条,如Android.
我尝试了以下内容,并找到了像deteminate这样的解决方案.
func startSendPickUpRequestShakeTimer () {
if self.movingViewTimer == nil {
self.movingViewTimer = Timer.scheduledTimer(
timeInterval: TimeInterval(movingViewSpeed),
target : self,
selector : #selector(self.startAnimating),
userInfo : nil,
repeats : true)
}
}
func startAnimating() {
let movingViewX = movingView.frame.minX >= view.frame.maxX ? 0-movingView.frame.width-forwardX:movingView.frame.minX + forwardX
self.movingView.frame = CGRect(x: movingViewX, y: movingView.frame.minY, width: movingView.frame.width, height: moviewViewHeight)
}
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能实现其他的,或者有什么好的资源可以做到这一点?
我可以通过使用显示键盘textField.becomeFirstResponder()或使用隐藏键盘textField.resignFirstResponder().
您可能会注意到iPhone默认消息应用程序,当我们滚动(或拖动)到底部时,键盘会平滑地隐藏.即使我们通过不触摸底部开始滚动(或拖动)到上部,键盘也会动态显示.
如果我有滚动视图或用户拖动到底部,那么我该如何实现它.
我试图在这里初始化我的自定义字体,但它显示错误.
extension UIFont {
@objc convenience init(myCoder aDecoder: NSCoder) {
if let fontDescriptor = aDecoder.decodeObject(forKey: "UIFontDescriptor") as? UIFontDescriptor {
if let fontAttribute = fontDescriptor.fontAttributes["NSCTFontUIUsageAttribute"] as? String { // HERE SHOWING THE ERROR
var fontName = ""
switch fontAttribute {
case "CTFontRegularUsage":
fontName = appFontName
case "CTFontEmphasizedUsage", "CTFontBoldUsage":
fontName = appFontBoldName
case "CTFontObliqueUsage":
fontName = appFontItalicName
default:
fontName = appFontName
}
self.init(name: fontName, size: fontDescriptor.pointSize)!
}
else {
self.init(myCoder: aDecoder)
}
}
else {
self.init(myCoder: aDecoder)
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
这适用于swift-3.2.但它没有运行swift-4.0.请帮我.提前致谢.
我有一个UITableView和一个countries变量,其签名如下:
let countryArray = ["Bangladesh", "India", "Pakistan", "Nepal", "Bhutan", "China", "Malaysia", "Myanmar", "Sri Lanka", "Saudi Arabia"]
Run Code Online (Sandbox Code Playgroud)
当我尝试在UITableView中绑定此国家/地区数组时,显示错误Generic parameter 'Self' could not be inferred。
这是我正在执行的代码段:
let countries = Observable.just(countryArray)
countries.bindTo(self.tableView.rx.items(cellIdentifier: "myCell",
cellType: MyCell.self)) {
row, country, cell in
// configuring cell
}
.addDisposableTo(disposeBag)
Run Code Online (Sandbox Code Playgroud)