Skeleton & Border Trail

Display

Two 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

PropertyDefaultDescription
lineWidth2Trail stroke width in points
cornerRadius16Must match container's corner radius
trailLength0.12Fraction of perimeter (0.01โ€“0.95)
duration2.4sTime for one full revolution
colorspurple/blue/tealGradient color stops
glowOpacity0.35Layer 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.