iOS development
UIButton animation
Pulse effect
Swift programming
Mobile UI design

How to do a native Pulse effect animation on a UIButton - iOS

Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms

Introduction

A pulse effect on UIButton is usually a scale animation that briefly enlarges and relaxes the control to draw attention or confirm a tap. On iOS, the most native-looking solution is to animate the button’s transform or layer rather than forcing layout changes.

A simple one-shot pulse with UIKit

For many use cases, a short transform animation is enough.

swift
1import UIKit
2
3func pulse(_ button: UIButton) {
4    UIView.animate(withDuration: 0.12, animations: {
5        button.transform = CGAffineTransform(scaleX: 1.08, y: 1.08)
6    }, completion: { _ in
7        UIView.animate(withDuration: 0.12) {
8            button.transform = .identity
9        }
10    })
11}

This is good for:

  • highlighting a primary call to action
  • confirming a successful tap
  • drawing short-term attention during onboarding

Because it uses transform animation, it is usually smooth and does not force Auto Layout to recalculate the whole interface.

Make it feel more natural with spring animation

If you want a softer, more iOS-like pulse, a spring animation often looks better than a rigid scale-up and scale-down.

swift
1import UIKit
2
3func springPulse(_ button: UIButton) {
4    button.transform = CGAffineTransform(scaleX: 0.96, y: 0.96)
5
6    UIView.animate(
7        withDuration: 0.4,
8        delay: 0,
9        usingSpringWithDamping: 0.45,
10        initialSpringVelocity: 3.0,
11        options: [.allowUserInteraction],
12        animations: {
13            button.transform = .identity
14        }
15    )
16}

This version starts slightly compressed and then relaxes back with a bounce. It often feels closer to the motion language users expect on iOS.

Use Core Animation for repeating pulses

If the button should pulse repeatedly, layer animation is a better fit.

swift
1import UIKit
2
3func startPulse(on button: UIButton) {
4    let animation = CABasicAnimation(keyPath: "transform.scale")
5    animation.fromValue = 1.0
6    animation.toValue = 1.08
7    animation.duration = 0.6
8    animation.autoreverses = true
9    animation.repeatCount = .infinity
10    animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
11
12    button.layer.add(animation, forKey: "pulse")
13}
14
15func stopPulse(on button: UIButton) {
16    button.layer.removeAnimation(forKey: "pulse")
17}

This is useful when you want the interface to gently signal "tap me" for a short period. It should be used carefully so the interface does not become visually noisy.

Trigger the pulse from touch handling

A common pattern is to pulse the button in its action method:

swift
1@IBAction private func continueTapped(_ sender: UIButton) {
2    springPulse(sender)
3    // Continue with the button action
4}

This creates a subtle visual confirmation without replacing the actual action logic.

You can also wrap the animation in a UIButton subclass if the effect should be reused across several screens.

Prefer transforms over frame manipulation

Changing frame, bounds, or constraints to fake a pulse usually creates more problems than it solves. Constraint-driven layouts can jump, and manual frame edits can fight Auto Layout.

Transform animation is better because:

  • it is lightweight
  • it is visually smooth
  • it does not require relayout
  • it is easy to reset with .identity

That makes it the standard choice for this kind of effect.

Use pulse sparingly

A pulse effect is strongest when it has a clear purpose. Good use cases include:

  • guiding the user to the next onboarding step
  • highlighting one primary action
  • confirming a successful interaction

Bad use cases include making every button pulse or leaving a repeated pulse active forever. Motion that never stops quickly turns from guidance into distraction.

Common Pitfalls

The biggest mistake is animating layout properties instead of transforms. That makes the effect harder to manage and can cause jitter with Auto Layout.

Another issue is scaling too aggressively. Large scale values make the button look jumpy and can cause overlap with nearby views.

Developers also forget to remove repeating animations when the view disappears or the UI state changes. An infinite pulse that keeps running off-screen or after the call to action is no longer relevant is just wasted motion.

Finally, an attention-grabbing pulse should still respect accessibility and interface clarity. If the motion competes with the rest of the screen, the animation is doing too much.

Summary

  • A native-feeling pulse on UIButton is usually a transform scale animation.
  • UIKit animations are ideal for one-shot pulses.
  • Spring animation often feels more natural than a rigid scale sequence.
  • Core Animation is useful for repeating pulses, but only when used sparingly.
  • Keep the effect subtle and purposeful so it supports the interface instead of distracting from it.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms