如何在Swift语言中将Gregorian datepicker转换为波斯语日期选择器?
func datePickerValueChanged(sender: UIDatePicker) {
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle
dateFormatter.timeStyle = NSDateFormatterStyle.NoStyle
dateFormatter.dateFormat = NSCalendarIdentifierPersian
dateOutlet.text = dateFormatter.stringFromDate(sender.date)
}
Run Code Online (Sandbox Code Playgroud)
我更改了日期格式,NSCalendarIdentifierPersian但datepicker没有任何变化?
我使用此代码在键盘出现时向上移动视图,在我的登录页面中此代码运行良好,但在注册页面中它不起作用。
func textFieldDidBeginEditing(textField: UITextField) {
animateViewMoving(true, moveValue: 100)
}
func textFieldDidEndEditing(textField: UITextField) {
animateViewMoving(false, moveValue: 100)
}
func animateViewMoving (up:Bool, moveValue :CGFloat){
var movementDuration:NSTimeInterval = 0.3
var movement:CGFloat = ( up ? -moveValue : moveValue)
UIView.beginAnimations( "animateView", context: nil)
UIView.setAnimationBeginsFromCurrentState(true)
UIView.setAnimationDuration(movementDuration )
self.view.frame = CGRectOffset(self.view.frame, 0, movement)
UIView.commitAnimations()
}
Run Code Online (Sandbox Code Playgroud)
我有另一个功能可以返回键盘上的键,它也可以在登录页面上运行,但在注册页面上不起作用。两页之间的所有内容都相同。
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
Run Code Online (Sandbox Code Playgroud)