iOS: Increase animation by click a button











up vote
1
down vote

favorite












I have the following animation, I need to implement a code, by clicking on a button the animation increased by one until a value that I want to reach it.



I try the following code:



    let strokeIt = CABasicAnimation(keyPath: "strokeEnd")
let timeLeftShapeLayer = CAShapeLayer()
let bgShapeLayer = CAShapeLayer()



override func viewDidLoad() {
drawBgShape()
drawTimeLeftShape()
}


func drawBgShape() {
bgShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
bgShapeLayer.strokeColor = UIColor.white.cgColor
bgShapeLayer.fillColor = UIColor.clear.cgColor
bgShapeLayer.lineWidth = 15
view.layer.addSublayer(bgShapeLayer)
}

func drawTimeLeftShape() {
timeLeftShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
timeLeftShapeLayer.lineWidth = 15
view.layer.addSublayer(timeLeftShapeLayer)
}


and when click a button :



     var x = 0.0
@IBAction func click(_ sender: Any) {

strokeIt.fromValue = x
strokeIt.toValue = x + 0.1

strokeIt.duration = 0.25
timeLeftShapeLayer.add(strokeIt, forKey: nil)
x = x + 0.1
}


How can I achieve that?
enter image description here










share|improve this question


























    up vote
    1
    down vote

    favorite












    I have the following animation, I need to implement a code, by clicking on a button the animation increased by one until a value that I want to reach it.



    I try the following code:



        let strokeIt = CABasicAnimation(keyPath: "strokeEnd")
    let timeLeftShapeLayer = CAShapeLayer()
    let bgShapeLayer = CAShapeLayer()



    override func viewDidLoad() {
    drawBgShape()
    drawTimeLeftShape()
    }


    func drawBgShape() {
    bgShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
    100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
    bgShapeLayer.strokeColor = UIColor.white.cgColor
    bgShapeLayer.fillColor = UIColor.clear.cgColor
    bgShapeLayer.lineWidth = 15
    view.layer.addSublayer(bgShapeLayer)
    }

    func drawTimeLeftShape() {
    timeLeftShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
    100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
    timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
    timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
    timeLeftShapeLayer.lineWidth = 15
    view.layer.addSublayer(timeLeftShapeLayer)
    }


    and when click a button :



         var x = 0.0
    @IBAction func click(_ sender: Any) {

    strokeIt.fromValue = x
    strokeIt.toValue = x + 0.1

    strokeIt.duration = 0.25
    timeLeftShapeLayer.add(strokeIt, forKey: nil)
    x = x + 0.1
    }


    How can I achieve that?
    enter image description here










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have the following animation, I need to implement a code, by clicking on a button the animation increased by one until a value that I want to reach it.



      I try the following code:



          let strokeIt = CABasicAnimation(keyPath: "strokeEnd")
      let timeLeftShapeLayer = CAShapeLayer()
      let bgShapeLayer = CAShapeLayer()



      override func viewDidLoad() {
      drawBgShape()
      drawTimeLeftShape()
      }


      func drawBgShape() {
      bgShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
      100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
      bgShapeLayer.strokeColor = UIColor.white.cgColor
      bgShapeLayer.fillColor = UIColor.clear.cgColor
      bgShapeLayer.lineWidth = 15
      view.layer.addSublayer(bgShapeLayer)
      }

      func drawTimeLeftShape() {
      timeLeftShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
      100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
      timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
      timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
      timeLeftShapeLayer.lineWidth = 15
      view.layer.addSublayer(timeLeftShapeLayer)
      }


      and when click a button :



           var x = 0.0
      @IBAction func click(_ sender: Any) {

      strokeIt.fromValue = x
      strokeIt.toValue = x + 0.1

      strokeIt.duration = 0.25
      timeLeftShapeLayer.add(strokeIt, forKey: nil)
      x = x + 0.1
      }


      How can I achieve that?
      enter image description here










      share|improve this question













      I have the following animation, I need to implement a code, by clicking on a button the animation increased by one until a value that I want to reach it.



      I try the following code:



          let strokeIt = CABasicAnimation(keyPath: "strokeEnd")
      let timeLeftShapeLayer = CAShapeLayer()
      let bgShapeLayer = CAShapeLayer()



      override func viewDidLoad() {
      drawBgShape()
      drawTimeLeftShape()
      }


      func drawBgShape() {
      bgShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
      100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
      bgShapeLayer.strokeColor = UIColor.white.cgColor
      bgShapeLayer.fillColor = UIColor.clear.cgColor
      bgShapeLayer.lineWidth = 15
      view.layer.addSublayer(bgShapeLayer)
      }

      func drawTimeLeftShape() {
      timeLeftShapeLayer.path = UIBezierPath(arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY), radius:
      100, startAngle: -90.degreesToRadians, endAngle: 270.degreesToRadians, clockwise: true).cgPath
      timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
      timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
      timeLeftShapeLayer.lineWidth = 15
      view.layer.addSublayer(timeLeftShapeLayer)
      }


      and when click a button :



           var x = 0.0
      @IBAction func click(_ sender: Any) {

      strokeIt.fromValue = x
      strokeIt.toValue = x + 0.1

      strokeIt.duration = 0.25
      timeLeftShapeLayer.add(strokeIt, forKey: nil)
      x = x + 0.1
      }


      How can I achieve that?
      enter image description here







      ios animation swift4 cabasicanimation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 11:11









      Ali A. Jalil

      998




      998
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You don't need to use an explicit animation to achieve this.



          For some properties of CALayer, Core Animation will add an implicit animation for you. The strokeEnd property is one of these.



          This means that Core Animation will automatically animate any changes to a layer's strokeEnd property. You don't need to create an animation object and add it yourself.



          There are a few things you'll need to amend with your implementation to get it working.



          1) The background circle, to look like the image you've posted, should have a grey strokeColor within your drawBgShape function:



          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor


          2) The strokeEnd for timeLeftShapeLayer should be set to 0.0 as its starting value within your drawTimeLeftShape function.



           timeLeftShapeLayer.strokeEnd = 0.0


          3) Remove the strokeIt animation property from your class, you don't need it.



          4) Update your click function to slowly increment the strokeEnd property of timeLeftShapeLayer directly. This is one simple line of code:



          timeLeftShapeLayer.strokeEnd += 0.1


          Here's an example implementation:



          class ViewController: UIViewController {

          let timeLeftShapeLayer = CAShapeLayer()
          let bgShapeLayer = CAShapeLayer()

          override func viewDidLoad() {
          super.viewDidLoad()
          drawBgShape()
          drawTimeLeftShape()
          }

          func drawBgShape() {
          bgShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor
          bgShapeLayer.fillColor = UIColor.clear.cgColor
          bgShapeLayer.lineWidth = 15
          view.layer.addSublayer(bgShapeLayer)
          }

          func drawTimeLeftShape() {
          timeLeftShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
          timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
          timeLeftShapeLayer.lineWidth = 15
          timeLeftShapeLayer.strokeEnd = 0.0
          view.layer.addSublayer(timeLeftShapeLayer)
          }

          @IBAction func click(_ sender: Any) {
          timeLeftShapeLayer.strokeEnd += 0.1
          }


          }





          share|improve this answer





















          • Thanks a lot, it's worked, but how to set max and min value of animation?
            – Ali A. Jalil
            Nov 10 at 13:09










          • You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
            – Pete Morris
            Nov 10 at 13:17






          • 1




            Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
            – Ali A. Jalil
            Nov 10 at 13:23











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224617%2fios-increase-animation-by-click-a-button%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          You don't need to use an explicit animation to achieve this.



          For some properties of CALayer, Core Animation will add an implicit animation for you. The strokeEnd property is one of these.



          This means that Core Animation will automatically animate any changes to a layer's strokeEnd property. You don't need to create an animation object and add it yourself.



          There are a few things you'll need to amend with your implementation to get it working.



          1) The background circle, to look like the image you've posted, should have a grey strokeColor within your drawBgShape function:



          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor


          2) The strokeEnd for timeLeftShapeLayer should be set to 0.0 as its starting value within your drawTimeLeftShape function.



           timeLeftShapeLayer.strokeEnd = 0.0


          3) Remove the strokeIt animation property from your class, you don't need it.



          4) Update your click function to slowly increment the strokeEnd property of timeLeftShapeLayer directly. This is one simple line of code:



          timeLeftShapeLayer.strokeEnd += 0.1


          Here's an example implementation:



          class ViewController: UIViewController {

          let timeLeftShapeLayer = CAShapeLayer()
          let bgShapeLayer = CAShapeLayer()

          override func viewDidLoad() {
          super.viewDidLoad()
          drawBgShape()
          drawTimeLeftShape()
          }

          func drawBgShape() {
          bgShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor
          bgShapeLayer.fillColor = UIColor.clear.cgColor
          bgShapeLayer.lineWidth = 15
          view.layer.addSublayer(bgShapeLayer)
          }

          func drawTimeLeftShape() {
          timeLeftShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
          timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
          timeLeftShapeLayer.lineWidth = 15
          timeLeftShapeLayer.strokeEnd = 0.0
          view.layer.addSublayer(timeLeftShapeLayer)
          }

          @IBAction func click(_ sender: Any) {
          timeLeftShapeLayer.strokeEnd += 0.1
          }


          }





          share|improve this answer





















          • Thanks a lot, it's worked, but how to set max and min value of animation?
            – Ali A. Jalil
            Nov 10 at 13:09










          • You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
            – Pete Morris
            Nov 10 at 13:17






          • 1




            Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
            – Ali A. Jalil
            Nov 10 at 13:23















          up vote
          1
          down vote



          accepted










          You don't need to use an explicit animation to achieve this.



          For some properties of CALayer, Core Animation will add an implicit animation for you. The strokeEnd property is one of these.



          This means that Core Animation will automatically animate any changes to a layer's strokeEnd property. You don't need to create an animation object and add it yourself.



          There are a few things you'll need to amend with your implementation to get it working.



          1) The background circle, to look like the image you've posted, should have a grey strokeColor within your drawBgShape function:



          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor


          2) The strokeEnd for timeLeftShapeLayer should be set to 0.0 as its starting value within your drawTimeLeftShape function.



           timeLeftShapeLayer.strokeEnd = 0.0


          3) Remove the strokeIt animation property from your class, you don't need it.



          4) Update your click function to slowly increment the strokeEnd property of timeLeftShapeLayer directly. This is one simple line of code:



          timeLeftShapeLayer.strokeEnd += 0.1


          Here's an example implementation:



          class ViewController: UIViewController {

          let timeLeftShapeLayer = CAShapeLayer()
          let bgShapeLayer = CAShapeLayer()

          override func viewDidLoad() {
          super.viewDidLoad()
          drawBgShape()
          drawTimeLeftShape()
          }

          func drawBgShape() {
          bgShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor
          bgShapeLayer.fillColor = UIColor.clear.cgColor
          bgShapeLayer.lineWidth = 15
          view.layer.addSublayer(bgShapeLayer)
          }

          func drawTimeLeftShape() {
          timeLeftShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
          timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
          timeLeftShapeLayer.lineWidth = 15
          timeLeftShapeLayer.strokeEnd = 0.0
          view.layer.addSublayer(timeLeftShapeLayer)
          }

          @IBAction func click(_ sender: Any) {
          timeLeftShapeLayer.strokeEnd += 0.1
          }


          }





          share|improve this answer





















          • Thanks a lot, it's worked, but how to set max and min value of animation?
            – Ali A. Jalil
            Nov 10 at 13:09










          • You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
            – Pete Morris
            Nov 10 at 13:17






          • 1




            Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
            – Ali A. Jalil
            Nov 10 at 13:23













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You don't need to use an explicit animation to achieve this.



          For some properties of CALayer, Core Animation will add an implicit animation for you. The strokeEnd property is one of these.



          This means that Core Animation will automatically animate any changes to a layer's strokeEnd property. You don't need to create an animation object and add it yourself.



          There are a few things you'll need to amend with your implementation to get it working.



          1) The background circle, to look like the image you've posted, should have a grey strokeColor within your drawBgShape function:



          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor


          2) The strokeEnd for timeLeftShapeLayer should be set to 0.0 as its starting value within your drawTimeLeftShape function.



           timeLeftShapeLayer.strokeEnd = 0.0


          3) Remove the strokeIt animation property from your class, you don't need it.



          4) Update your click function to slowly increment the strokeEnd property of timeLeftShapeLayer directly. This is one simple line of code:



          timeLeftShapeLayer.strokeEnd += 0.1


          Here's an example implementation:



          class ViewController: UIViewController {

          let timeLeftShapeLayer = CAShapeLayer()
          let bgShapeLayer = CAShapeLayer()

          override func viewDidLoad() {
          super.viewDidLoad()
          drawBgShape()
          drawTimeLeftShape()
          }

          func drawBgShape() {
          bgShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor
          bgShapeLayer.fillColor = UIColor.clear.cgColor
          bgShapeLayer.lineWidth = 15
          view.layer.addSublayer(bgShapeLayer)
          }

          func drawTimeLeftShape() {
          timeLeftShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
          timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
          timeLeftShapeLayer.lineWidth = 15
          timeLeftShapeLayer.strokeEnd = 0.0
          view.layer.addSublayer(timeLeftShapeLayer)
          }

          @IBAction func click(_ sender: Any) {
          timeLeftShapeLayer.strokeEnd += 0.1
          }


          }





          share|improve this answer












          You don't need to use an explicit animation to achieve this.



          For some properties of CALayer, Core Animation will add an implicit animation for you. The strokeEnd property is one of these.



          This means that Core Animation will automatically animate any changes to a layer's strokeEnd property. You don't need to create an animation object and add it yourself.



          There are a few things you'll need to amend with your implementation to get it working.



          1) The background circle, to look like the image you've posted, should have a grey strokeColor within your drawBgShape function:



          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor


          2) The strokeEnd for timeLeftShapeLayer should be set to 0.0 as its starting value within your drawTimeLeftShape function.



           timeLeftShapeLayer.strokeEnd = 0.0


          3) Remove the strokeIt animation property from your class, you don't need it.



          4) Update your click function to slowly increment the strokeEnd property of timeLeftShapeLayer directly. This is one simple line of code:



          timeLeftShapeLayer.strokeEnd += 0.1


          Here's an example implementation:



          class ViewController: UIViewController {

          let timeLeftShapeLayer = CAShapeLayer()
          let bgShapeLayer = CAShapeLayer()

          override func viewDidLoad() {
          super.viewDidLoad()
          drawBgShape()
          drawTimeLeftShape()
          }

          func drawBgShape() {
          bgShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          bgShapeLayer.strokeColor = UIColor.lightGray.cgColor
          bgShapeLayer.fillColor = UIColor.clear.cgColor
          bgShapeLayer.lineWidth = 15
          view.layer.addSublayer(bgShapeLayer)
          }

          func drawTimeLeftShape() {
          timeLeftShapeLayer.path = UIBezierPath(
          arcCenter: CGPoint(x: view.frame.midX , y: view.frame.midY),
          radius: 100,
          startAngle: -90.degreesToRadians,
          endAngle: 270.degreesToRadians,
          clockwise: true
          ).cgPath
          timeLeftShapeLayer.strokeColor = UIColor.red.cgColor
          timeLeftShapeLayer.fillColor = UIColor.clear.cgColor
          timeLeftShapeLayer.lineWidth = 15
          timeLeftShapeLayer.strokeEnd = 0.0
          view.layer.addSublayer(timeLeftShapeLayer)
          }

          @IBAction func click(_ sender: Any) {
          timeLeftShapeLayer.strokeEnd += 0.1
          }


          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 9 at 12:29









          Pete Morris

          748111




          748111












          • Thanks a lot, it's worked, but how to set max and min value of animation?
            – Ali A. Jalil
            Nov 10 at 13:09










          • You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
            – Pete Morris
            Nov 10 at 13:17






          • 1




            Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
            – Ali A. Jalil
            Nov 10 at 13:23


















          • Thanks a lot, it's worked, but how to set max and min value of animation?
            – Ali A. Jalil
            Nov 10 at 13:09










          • You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
            – Pete Morris
            Nov 10 at 13:17






          • 1




            Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
            – Ali A. Jalil
            Nov 10 at 13:23
















          Thanks a lot, it's worked, but how to set max and min value of animation?
          – Ali A. Jalil
          Nov 10 at 13:09




          Thanks a lot, it's worked, but how to set max and min value of animation?
          – Ali A. Jalil
          Nov 10 at 13:09












          You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
          – Pete Morris
          Nov 10 at 13:17




          You’re welcome. Not sure what you mean - are you talking about from and to values? If you could amend your question to explain the functionality you’re looking for it would help understand.
          – Pete Morris
          Nov 10 at 13:17




          1




          1




          Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
          – Ali A. Jalil
          Nov 10 at 13:23




          Thanks, I reached what I need. I want to set the stop value (max numbers of clicking) @IBAction func click(_ sender: Any) { timeLeftShapeLayer.strokeEnd += 1/34 if timeLeftShapeLayer.strokeEnd == 1 { timeLeftShapeLayer.strokeEnd = 0.0 } }
          – Ali A. Jalil
          Nov 10 at 13:23


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224617%2fios-increase-animation-by-click-a-button%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Academy of Television Arts & Sciences

          L'Équipe

          1995 France bombings