ios - Creating a completely custom UIRefreshControl -


i need create entirely custom uirefresh control. animation, image, pull down amount, etc...

my initial thought start scratch, use uiviewcontroller, add own view it, animate accessing uiscrollviewdelegate methods.

i can there way less work , easier add multiple uitableviews?

is possible subclass uirefreshcontrol , change amount of stuff inside it?

answer updated

  • github project update swift 3.1
  • updated quartzcode version 1.55.0 (changes on generated code)
  • code refactored use new refreshcontrol property (introduced in ios 10) (also more "swifty" now).
  • included @hanny's suggestion (down below) (thanks!)

i youtube link posted. :) nice result.

for reference: quartzcode pretty creating uirefreshcontrol animation scratch.

check out this little project (github). in it, find quartzcode project file example on how integrate uitableview.

i think important part in there refresh function:

/// called everytime refresh control's value changes. /// /// - parameter sender: `uirefreshcontrol` of tableview. @ibaction func refresh(_ sender: uirefreshcontrol) {      animate()      // in "demo", refresh last 5.0 seconds.     dispatchqueue.main.asyncafter(deadline: .now() + 5) {          // retrieved data...         // todo          // ... end refresh operation.         self.refreshcontrol?.endrefreshing()          // stop animations.         self.stopanimations()     } } 

look how easy use animations:

/// 3 examples. uncomment / comment check of them. func animate() {      // example 01.     animatecloudupanddown()      // example 02.     //animatecloudstrokewithgradientfill()      // example 03.     //animatecloudstrokewithsolidfill() }  // mark: - animation examples  /// animates cloud , down. func animatecloudupanddown() {     customuirefreshcontrol.addrefreshupdownanimation() }  /// "draws" cloud make stroke line gradually visible, shows /// solid blueish background , fades out. func animatecloudstrokewithgradientfill() {     customuirefreshcontrol.addrefreshgradientanimation() }  /// "draws" cloud make stroke line gradually visible, shows /// gradient blueish background , fades out. func animatecloudstrokewithsolidfill() {     customuirefreshcontrol.addrefreshsolidanimation() } 

cheers!


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -