mirror of
https://github.com/LeoNatan/LNPopupController.git
synced 2026-07-30 16:11:51 +00:00
Import latest LNPopupController master branch with iOS 12 fixes
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// IntroWebViewController.m
|
||||
// LNPopupControllerExample
|
||||
//
|
||||
// Created by Leo Natan on 10/28/20.
|
||||
// Copyright © 2020 Leo Natan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IntroWebViewController.h"
|
||||
@import WebKit;
|
||||
@import LNPopupController;
|
||||
|
||||
extern UIImage* LNSystemImage(NSString* named);
|
||||
|
||||
@interface IntroWebViewController ()
|
||||
{
|
||||
UIWebView* _webView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation IntroWebViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
_webView = [UIWebView new];
|
||||
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://github.com/LeoNatan/LNPopupController"]]];
|
||||
_webView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
// _webView.allowsBackForwardNavigationGestures = YES;
|
||||
// _webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
if (@available(iOS 13.0, *)) {
|
||||
_webView.scrollView.automaticallyAdjustsScrollIndicatorInsets = NO;
|
||||
}
|
||||
[self.view addSubview:_webView];
|
||||
|
||||
UIBlurEffectStyle style;
|
||||
if (@available(iOS 13.0, *)) {
|
||||
style = UIBlurEffectStyleSystemThinMaterial;
|
||||
} else {
|
||||
style = UIBlurEffectStyleExtraLight;
|
||||
}
|
||||
UIVisualEffectView* effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:style]];
|
||||
effectView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self.view addSubview:effectView];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[self.view.topAnchor constraintEqualToAnchor:_webView.topAnchor],
|
||||
[self.view.bottomAnchor constraintEqualToAnchor:_webView.bottomAnchor],
|
||||
[self.view.leadingAnchor constraintEqualToAnchor:_webView.leadingAnchor],
|
||||
[self.view.trailingAnchor constraintEqualToAnchor:_webView.trailingAnchor],
|
||||
|
||||
[self.view.topAnchor constraintEqualToAnchor:effectView.topAnchor],
|
||||
[self.view.safeAreaLayoutGuide.topAnchor constraintEqualToAnchor:effectView.bottomAnchor],
|
||||
[self.view.leadingAnchor constraintEqualToAnchor:effectView.leadingAnchor],
|
||||
[self.view.trailingAnchor constraintEqualToAnchor:effectView.trailingAnchor],
|
||||
]];
|
||||
|
||||
self.popupItem.image = [UIImage imageNamed:@"AppIcon60x60"];
|
||||
self.popupItem.barButtonItems = @[
|
||||
[[UIBarButtonItem alloc] initWithImage:LNSystemImage(@"suit.heart.fill") style:UIBarButtonItemStylePlain target:self action:@selector(_navigate:)],
|
||||
];
|
||||
|
||||
NSString* title = NSLocalizedString(@"Welcome to LNPopupController!", @"");
|
||||
|
||||
NSMutableAttributedString* attribTitle = [[NSMutableAttributedString alloc] initWithString:title];
|
||||
[attribTitle addAttributes:@{
|
||||
NSFontAttributeName: [[UIFontMetrics metricsForTextStyle:UIFontTextStyleBody] scaledFontForFont:[UIFont systemFontOfSize:15 weight:UIFontWeightMedium]],
|
||||
} range:NSMakeRange(0, attribTitle.length)];
|
||||
[attribTitle addAttributes: @{
|
||||
NSFontAttributeName: [[UIFontMetrics metricsForTextStyle:UIFontTextStyleHeadline] scaledFontForFont:[UIFont systemFontOfSize:16 weight:UIFontWeightHeavy]],
|
||||
} range:[title rangeOfString:NSLocalizedString(@"LNPopupController", @"")]];
|
||||
|
||||
self.popupItem.attributedTitle = attribTitle;
|
||||
}
|
||||
|
||||
- (IBAction)_navigate:(id)sender
|
||||
{
|
||||
[UIApplication.sharedApplication openURL:[NSURL URLWithString:@"https://github.com/LeoNatan/LNPopupController"] options:@{} completionHandler:nil];
|
||||
}
|
||||
|
||||
- (void)viewSafeAreaInsetsDidChange
|
||||
{
|
||||
[super viewSafeAreaInsetsDidChange];
|
||||
|
||||
_webView.scrollView.scrollIndicatorInsets = self.view.safeAreaInsets;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user