Skip to content

Commit

Permalink
[Banner] setNeedsLayout before showing Banner in BannerAutolayoutSwif…
Browse files Browse the repository at this point in the history
…tExampleViewController

PiperOrigin-RevId: 348569490
  • Loading branch information
wenyuzhang666 authored and material-automation committed Dec 22, 2020
1 parent b42de42 commit 1faf60e
Showing 1 changed file with 8 additions and 6 deletions.
Expand Up @@ -13,11 +13,10 @@
// limitations under the License.

import UIKit

import MaterialComponents.MaterialBanner
import MaterialComponents.MaterialBanner_Theming
import MaterialComponents.MaterialBanner_Theming
import MaterialComponents.MaterialButtons
import MaterialComponents.MaterialButtons_Theming
import MaterialComponents.MaterialButtons_Theming
import MaterialComponents.MaterialColorScheme
import MaterialComponents.MaterialContainerScheme

Expand All @@ -33,7 +32,8 @@ class BannerAutoLayoutSwiftExampleViewController: UIViewController {
showBannerButton.translatesAutoresizingMaskIntoConstraints = false
showBannerButton.applyTextTheme(withScheme: containerScheme)
showBannerButton.setTitle("Material Banner", for: .normal)
showBannerButton.addTarget(self, action: #selector(self.didTapShowBannerButton), for: .touchUpInside)
showBannerButton.addTarget(
self, action: #selector(self.didTapShowBannerButton), for: .touchUpInside)
view.addSubview(showBannerButton)
showBannerButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
showBannerButton.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
Expand All @@ -45,7 +45,8 @@ class BannerAutoLayoutSwiftExampleViewController: UIViewController {
bannerView.layoutMargins = .zero
let actionButton = bannerView.leadingButton
actionButton.setTitle("Dismiss", for: .normal)
actionButton.addTarget(self, action: #selector(self.didTapDismissOnBannerView), for: .touchUpInside)
actionButton.addTarget(
self, action: #selector(self.didTapDismissOnBannerView), for: .touchUpInside)
bannerView.applyTheme(withScheme: containerScheme)
view.addSubview(bannerView)
bannerView.isHidden = true
Expand All @@ -60,7 +61,8 @@ class BannerAutoLayoutSwiftExampleViewController: UIViewController {

@objc func didTapShowBannerButton() {
bannerView.isHidden = false
UIAccessibility.post(notification:.layoutChanged, argument: bannerView);
bannerView.setNeedsLayout()
UIAccessibility.post(notification: .layoutChanged, argument: bannerView)
}

@objc func didTapDismissOnBannerView() {
Expand Down

0 comments on commit 1faf60e

Please sign in to comment.