Adds shadow styling to CALayer based on a shadow model.
// Source: https://github.com/stripe/stripe-ios | License: MIT | Copyright 2011- Stripe, Inc. (https://stripe.com)
// Provided via justclaw.it.com; keep this notice with the code.
//
// CALayer+StripeUICore.swift
// StripeUICore
//
// Created by Nick Porter on 3/16/22.
// Copyright © 2022 Stripe, Inc. All rights reserved.
//
import Foundation
import QuartzCore
import UIKit
@_spi(STP) public extension CALayer {
func applyShadow(shadow: ElementsAppearance.Shadow?) {
guard let shadow = shadow else {
shadowOpacity = 0
return
}
shadowColor = shadow.color.cgColor
shadowOpacity = Float(shadow.opacity)
shadowOffset = shadow.offset
shadowRadius = CGFloat(shadow.radius)
}
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key