Issue : I have use below code to change Title and set underline of UIButton at run time. [btnTemp setTitle:@”Test” forState:UIControlStateNormal]; I have got below issues: 1. Underline is not showing 2. Title not change 3. Title color is display default black. To overcome this …
iPhone
Display list of UITextField in UITableview
Question : How to make list of UITextField in UITableview ? Review the below steps and try your own. 1. Implement one model class of .h and .m which is subclass of NSObject. //Here Class name is TextFieldFormElement.h and TextFieldFormElement.m 2. Declare the property for …
Read facebook and phone contacts with permission
Contact typealias CheckContactPermission = (Bool,ABAddressBook?) -> () func checkcontactpermission(pCompletionBlock:CheckContactPermission){ // make sure user hadn’t previously denied access let status = ABAddressBookGetAuthorizationStatus() if status == .Denied || status == .Restricted { // Helper.showAlert(ALERTCONTACTPERMISIONDNIED, pobjView: self.view) // user previously denied, so tell them to fix that in …
Get color of CGPoint from image in UIImageView
Method for fetching color of CGPoint from image in UIImageView :- extension UIImageView { func getColorOfPoint(_ point:CGPoint)->UIColor { var pixel:[CUnsignedChar] = [0,0,0,0] let colorSpace = CGColorSpaceCreateDeviceRGB() let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue) let context = CGContext(data: &pixel, width: 1, height: 1, bitsPerComponent: 8, bytesPerRow: 4, space: colorSpace, …
Extension for Dictionary
Get Dictionary after removing all null values :- extension Dictionary where Value: Any { func nullsRemoved() -> Dictionary { var dicOriginal = self let keysToRemove = Array(dicOriginal.keys).filter { dicOriginal[$0] is NSNull } for key in keysToRemove { dicOriginal.removeValue(forKey: key) } return dicOriginal } } …
Get Date Difference between two dates
Method to get difference between two dates :- ex :- static func getDateDifferenceforDate(_ pobjFirstDate: Date, andDate pobjLastDate: Date) -> String { var strTime: String let distanceBetweenDates: TimeInterval = pobjLastDate.timeIntervalSince(pobjFirstDate) let secondsInAnHour: Double = 3600 …
Animate app logo as as like instagram on home screen
To overcome I have made custom code to implement this follow below code: private var lastContentOffset: CGFloat = CGFloat(kInt0) var intScrollLogo: CGFloat = CGFloat(kInt0) @IBOutlet weak var viewNavigationHeightConstraint: NSLayoutConstraint! let kInt0 = 0 let kInt1 = 1 let kInt64 = 64 let kInt22 = 22 …
Layout issues after updating to Xcode 8
STEP 1: Open your storyboard in Xcode 8 and choose an initial device view. Make changes as you normally would. STEP 2: Once you have completed your changes, select the storyboard -> File Inspector -> Opens in -> Select ‘Xcode 7.x’. STEP 3: Select ‘Save …
Custom notification in iOS 10 or greater
After iOS 10 version you can also display images, GIF or videos in your notification. you need to do following things in your project. Step 1 : Add NotificationServiceExtension in your project targets. step 2 : Write following code in your NotificationServiceExtension.swift file. import UserNotifications …
Parse Your BLE Peripheral Device Characteristic in HEX String
#pragma mark – Peripheral Delegates – (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { if (error) NSLog(@”Error reading BLE data: %@”,[error localizedDescription]); else [self parseBLEMessage:characteristic.value]; } – (void)parseBLEMessage:(NSData*)pobjData { NSData *objData = pobjData; NSString *strValue = [getHexString:objdata]; } -(NSString*)getHexString:(NSData*)pdata { NSMutableString *sbuf; NSUInteger capacity = self.length …