Skeleton & Border Trail
DisplayTwo animated display components: TTBaseSkeletonMarkView โ a simple shimmer placeholder for loading states, and TTBaseBorderTrailView โ an animated gradient arc that races around a view's border (Motion-Primitives inspired).
๐ TTBaseSkeletonMarkView
A TTBaseUIView subclass that sets its background to viewBgSkeleton with default corner radius. Drop it anywhere to indicate loading content.
// Over any view
let skeleton = TTBaseSkeletonMarkView()
imageView.addSubview(skeleton)
skeleton.setFullContraints(constant: 0)
// Remove when data loads
URLSession.shared.dataTask(with: url) { data, _, _ in
DispatchQueue.main.async {
UIView.animate(withDuration: 0.2) { skeleton.alpha = 0 }
skeleton.removeFromSuperview()
imageView.image = UIImage(data: data!)
}
}.resume()
// Array of skeleton rows (list shimmer)
let skeletonViews: [TTBaseSkeletonMarkView] = (0..<5).map { _ in
let v = TTBaseSkeletonMarkView()
v.setHeightAnchor(constant: 60)
return v
}
stackView.addArrangedSubviews(skeletonViews)
โจ TTBaseBorderTrailView
An animated gradient border arc that loops endlessly around the view. Powered by CAGradientLayer (conic) + CAShapeLayer mask animations. Non-interactive โ layer on top of any view.
// Default config: purpleโblueโteal trail
let trail = TTBaseBorderTrailView()
containerView.addSubview(trail)
trail.setFullContraints(constant: 0)
trail.start()
// Custom config
let config = TTBaseBorderTrailView.Config(
lineWidth: 3,
cornerRadius: 20,
trailLength: 0.15, // 15% of perimeter
duration: 1.8,
colors: [.systemOrange, .systemPink, .systemPurple],
glowOpacity: 0.5
)
let trail = TTBaseBorderTrailView(config: config)
buttonView.addSubview(trail)
trail.setFullContraints(constant: 0)
trail.start()
// Stop animation
trail.stop()
// Update config at runtime (auto restarts)
trail.config.colors = [.systemGreen, .systemTeal]
๐ TTBaseBorderTrailView.Config
| Property | Default | Description |
|---|---|---|
lineWidth | 2 | Trail stroke width in points |
cornerRadius | 16 | Must match container's corner radius |
trailLength | 0.12 | Fraction of perimeter (0.01โ0.95) |
duration | 2.4s | Time for one full revolution |
colors | purple/blue/teal | Gradient color stops |
glowOpacity | 0.35 | Layer shadow intensity (0 = off) |
Pro Tip: Use
TTBaseBorderTrailView on premium CTAs, active cards, or loading states. Set isUserInteractionEnabled = false (already default) so touches pass through to the underlying view.