Posts

Showing posts from March, 2023

Gradiun Slider Swift5 storyboard iOS

Gradian Coloured Slider using Swift5   download demo code from here:- https://gitlab.com/hiren_syl/gradiunslider it's easy to make slider as Gradian Coloured.  for code:- func setSlider(slider: UISlider ) { let tgl = CAGradientLayer () let frame = CGRectMake ( 0 , 0 , slider.frame.size.width, 5 ) tgl.frame = frame tgl.colors = [ UIColor .blueColor().CGColor, UIColor .greenColor().CGColor, UIColor .yellowColor().CGColor, UIColor .orangeColor().CGColor, UIColor .redColor().CGColor] tgl.startPoint = CGPointMake ( 0.0 , 0.5 ) tgl.endPoint = CGPointMake ( 1.0 , 0.5 ) UIGraphicsBeginImageContextWithOptions (tgl.frame.size, tgl.opaque, 0.0 ); tgl.renderInContext( UIGraphicsGetCurrentContext ()!) let image = UIGraphicsGetImageFromCurrentImageContext () UIGraphicsEndImageContext () image.resizableImageWithCapInsets( UIEdgeInsetsZero ) slider.setMinimumTrackImage(image, forState: .Normal) //slider.setMaximumTrackImage(image, forSta...

CoreData Swift5 Demo Project iOS

CoreData #swift5 link to download dempo project:- https://gitlab.com/hiren_syl/todo-coredata Use Core Data  to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device . To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container. Delete A Core Data Object // Delete the entity from the context context . delete ( user ) // To delete the entity from the persistent store, call // save on the context do { try context . save ( ) } catch { // Handle Error } New NSManagedObject Example // Create a new UserEntity in the // NSManagedObjectContext context let user = UserEntity ( context : context ) // Assign values to the entity's properties user . name = "User Name" user . email = "user@domain.com" user . age = 32 // To save the new entity to the persistent store, call // sav...

SQLite Project Swift5 iOS

 Why SQLite? SQLite is  used to develop embedded software for devices like televisions, cell phones, cameras, etc . It can manage low to medium-traffic HTTP requests. SQLite can change files into smaller size archives with lesser metadata. SQLite is used as a temporary dataset to get processed with some data within an application. download code from here: https://gitlab.com/hiren_syl/sqlite-app code:- var db : OpaquePointer? var path : String = "myDataBaseName.sqlite" init() { self.db = createDB() self.createTable() } func createDB() -> OpaquePointer? { let filePath = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathExtension(path) var db : OpaquePointer? = nil if sqlite3_open(filePath.path, &db) != SQLITE_OK { print("There is error in creating DB") return nil }else { ...

Local Notification App Swift5 iOS

  Download Demo Code From Here 👇🏻 https://gitlab.com/hiren_syl/local-notifications let userNotificationCenter = UNUserNotificationCenter . current ( ) &&& override func viewDidLoad ( ) { super . viewDidLoad ( ) self . requestNotificationAuthorization ( ) self . sendNotification ( ) } &&& let authOptions = UNAuthorizationOptions . init ( arrayLiteral : . alert , . badge , . sound ) &&& func requestNotificationAuthorization ( ) { let authOptions = UNAuthorizationOptions . init ( arrayLiteral : . alert , . badge , . sound ) self . userNotificationCenter . requestAuthorization ( options : authOptions ) { ( success , error ) in if let error = error { print ( "Error: " , error ) } } } &&& // Create new notifcation content instance let notificationContent = UNMutableNotificationContent ( ) // Add the content to the notification content ...