Showing: 41 - 50 of 71 Articles

Remove emoji from text field/text view

set keyboard type to UIKeyboardTypeASCIICapable (txtField.keyboardType=UIKeyboardTypeASCIICapable;) you can find swift code from below link – (BOOL)stringContainsEmoji:(NSString *)string { __block BOOL returnValue = NO; [string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock: ^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { const unichar hs = [substring characterAtIndex:0]; // …

Push notification using firebase

Never Forget to define your REVERSED_CLIENT_ID (provided in GoogleService info.plist file) to your project target ->Info->URLschema . //Add your APNS certificate in the application created in Firebase. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {         let settings = UIUserNotificationSettings(types: …

Date to String and String to Date with Time Zone

// Methods to get string from date public func setStringfromDate(date : Date, dateFormate : String, timezone : TimeZone) -> String {     let dateFormatter = DateFormatter()     dateFormatter.timeZone = timezone     dateFormatter.dateFormat = dateFormate     return dateFormatter.string(from: date) } // MARK: –  String to Date …

How mobile number to be displayed as (XXX)-(XXX)-XXXX as the user types?

Code given below will help you to format mobile number like (XXX)-(XXX)-XXXX you just need to call this method in your shouldChangeCharactersIn method like this, func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { // phonenumber write in specific formate if …

Get date before year

public func getDateBeforeYear(year : Int) -> Date{     let gregorian: NSCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)!     let currentDate: Date = Date()     let components: NSDateComponents = NSDateComponents()          components.year = -year     return gregorian.date(byAdding: components as DateComponents, to: currentDate, options: NSCalendar.Options(rawValue: 0))! }

UILable Text Spacing

extension UILabel{     func setTextSpacing(spacing: CGFloat){         let attributedString = NSMutableAttributedString(string: text!)         if textAlignment == .center || textAlignment == .right {             attributedString.addAttribute(NSKernAttributeName, value: spacing, range: NSRange(location: 0, length: attributedString.length-1))         } else {             attributedString.addAttribute(NSKernAttributeName, value: spacing, range: NSRange(location: 0, length: attributedString.length))         …