-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #792 from stripe/bdorfman-custom-footer
Add custom footer view support
- Loading branch information
Showing
11 changed files
with
195 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Example/Standard Integration (Swift)/PaymentContextFooterView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// PaymentContextFooterView.swift | ||
// Standard Integration (Swift) | ||
// | ||
// Created by Brian Dorfman on 10/13/17. | ||
// Copyright © 2017 Stripe. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import Stripe | ||
|
||
class PaymentContextFooterView: UIView { | ||
|
||
var insetMargins: UIEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10) | ||
|
||
var text: String = "" { | ||
didSet { | ||
textLabel.text = text | ||
} | ||
} | ||
|
||
var theme: STPTheme = STPTheme.default() { | ||
didSet { | ||
textLabel.font = theme.smallFont | ||
textLabel.textColor = theme.secondaryForegroundColor | ||
} | ||
} | ||
|
||
fileprivate let textLabel = UILabel() | ||
|
||
convenience init(text: String) { | ||
self.init() | ||
textLabel.numberOfLines = 0 | ||
textLabel.textAlignment = .center | ||
self.addSubview(textLabel) | ||
|
||
self.text = text | ||
textLabel.text = text | ||
|
||
} | ||
|
||
override func layoutSubviews() { | ||
textLabel.frame = UIEdgeInsetsInsetRect(self.bounds, insetMargins) | ||
} | ||
|
||
override func sizeThatFits(_ size: CGSize) -> CGSize { | ||
// Add 10 pt border on all sides | ||
var insetSize = size | ||
insetSize.width -= (insetMargins.left + insetMargins.right) | ||
insetSize.height -= (insetMargins.top + insetMargins.bottom) | ||
|
||
var newSize = textLabel.sizeThatFits(insetSize) | ||
|
||
newSize.width += (insetMargins.left + insetMargins.right) | ||
newSize.height += (insetMargins.top + insetMargins.bottom) | ||
|
||
return newSize | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters