KevinZ
KevinZ

Reputation: 766

Adding shadow to UIView that is positioned using SnapKit

I have positioned a UIView using SnapKit and need to find a way to add a shadow. Because I positioned the view relative to other UIViews, I do not have the height, width, or starting coordinate of the view. How can I add a shadow to this UIView positioned using SnapKit auto layout. The code to position the UIView is this:

tableViewBackground.snp.makeConstraints{ (make) -> Void in
        make.width.lessThanOrEqualToSuperview()
        make.height.lessThanOrEqualToSuperview()
        make.right.equalToSuperview().offset(-20)
        make.left.equalToSuperview().offset(20)
        make.bottom.equalToSuperview().offset(-20)
        make.top.equalTo(poiLabel.snp.bottom).offset(20)
}

Upvotes: 1

Views: 739

Answers (1)

KevinZ
KevinZ

Reputation: 766

Moved the creation of the shadow layer from viewDidLoad to viewDidLayoutSubviews

Upvotes: 2

Related Questions