Is there an ActivityIndicator in WatchKit for Apple Watch?

后端 未结 8 1102
轮回少年
轮回少年 2020-11-30 07:29

Is there an ActivityIndicator (or something like it) in WatchKit for Apple Watch? How do you all give the user feedback about some longer lasting background activity?

相关标签:
8条回答
  • 2020-11-30 08:04

    There is no method for displaying ActivityIndicator in WatchKit Framework. However you can prepare some circular image and easily create infinite animation yourself. Prepare images and name them like this frame-0, frame-1, frame-2...frame-n

    and then in your code:

        [self.yourInterfaceImage setImageNamed:@"firstFrame-"]; //setting first frame
        [self.yourInterfaceImage startAnimatingWithImagesInRange:[self.model imageRange]
                                                   duration:0.4
                                                repeatCount:0];
        // [self.model imageRange] will return NSRange from 0 to n
        // repeatCount == 0 means infinity. Of course you can set some limit, like 100.
    

    Hope this helps.

    0 讨论(0)
  • 2020-11-30 08:06

    watchKit do not have indicator object. so use image to show indicator. Add your image in assets

    And use this code to start animate image

            image.setImageNamed("Small_Indicator")
            image.startAnimatingWithImages(in: NSMakeRange(0, 39), duration: 1.0, repeatCount: 0)
    

    And use this code to stop

            image.stopAnimating()
            image.setHidden(true)
    

    Refer the link and Use this sample project to show indicator https://github.com/Abishekt97/AppleWatchIndicator

    0 讨论(0)
提交回复
热议问题