去掉字符串中的空格和回车 获取键盘高度 判断字符串是否为空 swift

<span style="font-size:18px;">//判断字符串是否为空
func trimString(#str:String)->String{
    var nowStr = str.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
    return nowStr
}
//去除空格和回车
func trimLineString(#str:String)->String{
    var nowStr = str.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
    return nowStr
}
//根据键盘监控  获取键盘高度
func getKeyBoardHeight(#aNotification:NSNotification)->CGFloat{
    var uInfo   = aNotification.userInfo as NSDictionary!
    let avalue = uInfo["UIKeyboardFrameEndUserInfoKey"] as NSValue
    let keyrect : CGRect = avalue.CGRectValue()
    let keyheight : CGFloat = keyrect.size.height;
    return keyheight
}</span>

你可能感兴趣的:(String,swift)