Open alialki opened 10 years ago
So there's been a lot of changes to Swift since I wrote this, so it doesn't really compile. The last known version was updated recently for Version 6.1 (6A1042b). It should work on that.
I was trying to work with UIAppearance
to modify the appearance easily (especially for UIKeyboardAppearanceDark
and UIKeyboardApperanceLight
) but early on in the iOS 8 developer betas, it was too unstable for me to get that working. If that was fixed, "theming" would be easy.
oh ok so my version is the 6.1 (6A1046a) which based on the build number i think its newer
oh ok hope i can sort out the build errors cause the design is brilliant
ok i think i kind of fixed the problem and everything is fine until i test the app on my iPhone it crashes giving me this
this is also the code that i changed
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var textView: UITextView!
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// Custom initialization
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Custom initialization
registerForKeyboardNotifications()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
resetTextViewInsets()
}
func registerForKeyboardNotifications() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
// NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillChangeFrame:", name: UIKeyboardWillChangeFrameNotification, object: nil)
}
// Called when `UIKeyboardWillShowNotification` is sent.
func keyboardWillShow(aNotification: NSNotification) {
var info = aNotification.userInfo!
let sizeBegin = (info[UIKeyboardFrameBeginUserInfoKey] as NSValue).CGRectValue().size
let sizeEnd = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue().size
let duration = (info[UIKeyboardAnimationDurationUserInfoKey] as NSString).doubleValue
let curve = (info[UIKeyboardAnimationCurveUserInfoKey] as NSString).integerValue
var animationCurve: UIViewAnimationCurve
if let value = UIViewAnimationCurve(rawValue: curve) {
animationCurve = value
} else {
animationCurve = UIViewAnimationCurve.EaseInOut
}
let insets = UIEdgeInsets(top: 44, left: 0, bottom: sizeEnd.height, right: 0)
UIView.animateWithDuration(duration, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
self.textView.contentInset = insets
self.textView.scrollIndicatorInsets = insets
}, completion: nil)
}
// Called when `UIKeyboardWillHideNotification` is sent.
func keyboardWillHide(aNotification: NSNotification) {
var info = aNotification.userInfo!
let sizeBegin = (info[UIKeyboardFrameBeginUserInfoKey] as NSValue).CGRectValue().size
let sizeEnd = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue().size
let duration = (info[UIKeyboardAnimationDurationUserInfoKey] as NSString).doubleValue
let curve = (info[UIKeyboardAnimationCurveUserInfoKey] as NSString).integerValue
var animationCurve: UIViewAnimationCurve
if let value = UIViewAnimationCurve(rawValue: curve) {
animationCurve = value
} else {
animationCurve = UIViewAnimationCurve.EaseInOut
}
let insets = UIEdgeInsets(top: 44, left: 0, bottom: sizeEnd.height, right: 0)
UIView.animateWithDuration(duration, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
self.textView.contentInset = insets
self.textView.scrollIndicatorInsets = insets
}, completion: nil)
}
func resetTextViewInsets() {
let contentInsets = UIEdgeInsets(top: 44, left: 0, bottom: 0, right: 0);
textView.contentInset = contentInsets;
textView.scrollIndicatorInsets = contentInsets;
}
override func prefersStatusBarHidden() -> Bool {
return true
}
@IBAction func done(sender: AnyObject) {
textView.resignFirstResponder()
}
@IBAction func didChangeKeyboardAppearance(sender : UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 2: // .Dark
textView.keyboardAppearance = .Dark
case 1: // .Light
textView.keyboardAppearance = .Light
case 0: // .Default
textView.keyboardAppearance = .Default
default:
textView.keyboardAppearance = .Default
}
}
}
ok fixed the problem again import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var textView: UITextView!
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// Custom initialization
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Custom initialization
registerForKeyboardNotifications()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
resetTextViewInsets()
}
func registerForKeyboardNotifications() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil)
// NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillChangeFrame:", name: UIKeyboardWillChangeFrameNotification, object: nil)
}
// Called when `UIKeyboardWillShowNotification` is sent.
func keyboardWillShow(aNotification: NSNotification) {
if let info = aNotification.userInfo{
let sizeBegin = (info[UIKeyboardFrameBeginUserInfoKey] as NSValue).CGRectValue().size
let sizeEnd = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue().size
let duration = (info[UIKeyboardAnimationDurationUserInfoKey] as NSNumber).doubleValue
let curve = (info[UIKeyboardAnimationCurveUserInfoKey] as NSNumber).integerValue
var animationCurve: UIViewAnimationCurve
if let value = UIViewAnimationCurve(rawValue: curve) {
animationCurve = value
} else {
animationCurve = UIViewAnimationCurve.EaseInOut
}
let insets = UIEdgeInsets(top: 44, left: 0, bottom: sizeEnd.height, right: 0)
UIView.animateWithDuration(duration, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
self.textView.contentInset = insets
self.textView.scrollIndicatorInsets = insets
}, completion: nil)
} }
// Called when `UIKeyboardWillHideNotification` is sent.
func keyboardWillHide(aNotification: NSNotification) {
if let info = aNotification.userInfo{
let sizeBegin = (info[UIKeyboardFrameBeginUserInfoKey] as NSValue).CGRectValue().size
let sizeEnd = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue().size
let duration = (info[UIKeyboardAnimationDurationUserInfoKey] as NSNumber).doubleValue
let curve = (info[UIKeyboardAnimationCurveUserInfoKey] as NSNumber).integerValue
var animationCurve: UIViewAnimationCurve
if let value = UIViewAnimationCurve(rawValue: curve) {
animationCurve = value
} else {
animationCurve = UIViewAnimationCurve.EaseInOut
}
let insets = UIEdgeInsets(top: 44, left: 0, bottom: sizeEnd.height, right: 0)
UIView.animateWithDuration(duration, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
self.textView.contentInset = insets
self.textView.scrollIndicatorInsets = insets
}, completion: nil)
}
}
func resetTextViewInsets() {
let contentInsets = UIEdgeInsets(top: 44, left: 0, bottom: 0, right: 0);
textView.contentInset = contentInsets;
textView.scrollIndicatorInsets = contentInsets;
}
override func prefersStatusBarHidden() -> Bool {
return true
}
@IBAction func done(sender: AnyObject) {
textView.resignFirstResponder()
}
@IBAction func didChangeKeyboardAppearance(sender : UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 2: // .Dark
textView.keyboardAppearance = .Dark
case 1: // .Light
textView.keyboardAppearance = .Light
case 0: // .Default
textView.keyboardAppearance = .Default
default:
textView.keyboardAppearance = .Default
}
}
}
but now i am facing another problem the keyboard is not showing up in the keyboard settings in order to be added
UPDATED: ok i manage to fix it the keyboard extension was not linked properly and i have started to tweaking around and see what happens and trying to fix couple of themes to it i will upload then, but it would be great if you can help me out with the numbers and symbols how set that and switch to and from the symbols to the letters
hey there love the keyboard first of all i keep getting errors in the viewControllers.swift
and as i am new to swift i haven't got a hang of it yet if you could help me out how to resolve these errors that would be great also i had question is it possible to add themes to the keyboard easily ?