Skip to content

Commit

Permalink
Merge pull request alexaubry#3 from adriansoghoian/backgroundImage
Browse files Browse the repository at this point in the history
Add optional backgroundView to card
  • Loading branch information
adriansoghoian authored Feb 22, 2018
2 parents bf13876 + 1c63bfc commit 1588a60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/BulletinManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ import UIKit

// MARK: - Card Presentation

/**
* A background view applied to card itself.
*/

@objc public var cardBackgroundView: UIView?

/**
* The spacing between the edge of the screen and the edge of the card. Defaults to regular.
*
Expand Down
12 changes: 12 additions & 0 deletions Sources/Support/BulletinViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ extension BulletinViewController {
contentBottomConstraint.constant = 1000
contentBottomConstraint.isActive = true

// background image
if let backgroundView = manager.cardBackgroundView {
backgroundView.layer.cornerRadius = contentView.layer.cornerRadius
contentView.addSubview(backgroundView)
contentView.sendSubview(toBack: backgroundView)
NSLayoutConstraint.activate([
backgroundView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
backgroundView.topAnchor.constraint(equalTo: contentView.topAnchor),
backgroundView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
backgroundView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
])
}
}

// MARK: - Gesture Recognizer
Expand Down

0 comments on commit 1588a60

Please sign in to comment.