Posts

Showing posts from January, 2024

Menu popover from bottom to top sliding iOS swift

 Problem: I want to show popover from bottom to top sliding like material design.How can i achieve that? Solution: First need to add expanding menu in pods and install it.Then proceed with the below code. import   ExpandingMenu      fileprivate   func   configMenuButton () {            let   menuButtonSize:   CGSize   =   CGSize ( width : 50.0,   height : 50.0)              menuButton   =   ExpandingMenuButton ( frame :   self . myBtn . frame ,   image : "ImgName" ,   rotatedImage : "ImgName" )             self . view . addSubview ( menuButto n )             self . view . bringSubviewToFront ( menuButton )           menuButton . center   =   self . myBtn . center             var   menuItems:[ ExpandingMenuItem ] = []             for   i   in   0..< OptionsList . allC ases . count   {                 let   menuItem =   OptionsList ( rawValue : i)                 let   item1 =   ExpandingMenuItem ( size : menuButtonSize,   title : menuItem?. title ,   image : (menu

calendarKit day view swipe detection in day view swift

 Problem: I want to detect the swipe that user swiped the dayview to next or previous week.How can i achieve that?.No methods are detected for delegate options. Solution: func   eventsForDate ( _   date:   Date ) -> [CalendarKit. EventDescriptor ] {           if   ( calenderView . displayDate ?. sta rtOfWeek   != date. localDate (). startOfWeek ) {               dateSelected ( date :date. localDa te ())               loadData ( date : date. localDate ()) // use your own function to load the data with the weekview           }   else   {          }           return   []       }

Date Extension functions for iOS swift

The below are the extension functions that will be used for our app to extend the default functionality of the date datatyoe. extension   Date  {     //It can be used for get the first date of the month      func   startOfMonth () ->  Date  {          var  start =  self . addDays ( daysToAdd : - self . getDay ())          start = start. addDays ( daysToAdd : 1)          return  start     }          //It can be used for get the end date of the month      func   endOfMonth () ->  Date  {          return   Calendar . current . date ( byAdding :  DateComponents ( month : 1,  day : -1),  to :  self . startOfMonth ())!     }     //It can be used for get the first date of the week      var   startOfWeek :  Date  {          let  gregorian =  Calendar ( identifier : . gregorian )          guard   let  sunday = gregorian. date ( from : gregorian. dateComponents ([. yea rForWeekOfYear , . weekOfYear ],  from :  self ))  else  {  return   Date () }          return  gregorian. date ( byAdding