- (void) perform{ // , UIViewController *src = (UIViewController *) self.sourceViewController; UIViewController *dst = (UIViewController *) self.destinationViewController; // [UIView transitionFromView:src.view toView:dst.view duration:1 options:UIViewAnimationOptionTransitionFlipFromBottom completion:nil]; // Navigation Controller'a [UIView transitionFromView:src.navigationItem.titleView toView:dst.navigationItem.titleView duration:1 options:UIViewAnimationOptionTransitionFlipFromBottom completion:nil]; // Push Segue [src.navigationController pushViewController:dst animated:NO]; }
- (void)awakeFromNib { [super awakeFromNib]; self.layer.cornerRadius = 5.0f; self.layer.masksToBounds = YES; self.layer.borderColor = [UIColor whiteColor].CGColor; self.layer.borderWidth = 1.0f; }
NSString *htmlString; NSString *cssString; <... ...> htmlString = [NSString stringWithFormat:@"<style>%@</style>%@", cssString, htmlString]; NSURL *url = [[NSURL alloc] initFileURLWithPath:pathToApplicationDirectory]; [self hideOverscrollShadowsForWebView:webView]; [webView loadHTMLString:htmlString baseURL:url];
/*! , UIWebView \param webView WebView, */ - (void)hideOverscrollShadowsForWebView:(UIWebView *)webView { id scrollview = [webView.subviews objectAtIndex:0]; for (UIView *subview in [scrollview subviews]) if ([subview isKindOfClass:[UIImageView class]]) subview.hidden = YES; webView.backgroundColor = [UIColor clearColor]; }
#import <UIKit/UIKit.h> @interface PopupView : UIView @property (strong, nonatomic) IBOutlet UIView *backgroundView; @property (strong, nonatomic) IBOutlet UIView *innerPopupView; @property (strong, nonatomic) IBOutlet UILabel *popupTitleLabel; @property (strong, nonatomic) IBOutlet UILabel *popupTextLabel; @property (strong, nonatomic) IBOutlet UIButton *popupButton; @end
#import <Foundation/Foundation.h> #import "PopupControllerDelegate.h" #import "PopupView.h" @interface PopupController : NSObject // UIViewController, PopupView @property (strong, nonatomic) UIViewController<PopupControllerDelegate> *delegate; // . ! @property (strong, nonatomic) NSMutableArray *activePopups; - (IBAction)touchedButton:(UIButton *)sender; - (id)initWithDelegate:(UIViewController<PopupControllerDelegate> *)delegate; - (void)showHelloWorldPopup; - (void)dismissAllPopups; @end
#import "PopupController.h" @implementation PopupController - (id)initWithDelegate:(UIViewController<PopupControllerDelegate> *)delegate { self = [super init]; if (self) { // self.activePopups = [NSMutableArray array]; // self.delegate = delegate; } return self; } - (void)showHelloWorldPopup { PopupView *popup = [self popupFromRestorationID:@"text"]; [self configurePopup:popup]; [self showPopup:popup]; } - (IBAction)touchedButton:(UIButton *)sender { [self.delegate touchedPopupButton:sender]; } - (void)dismissAllPopups { for (UIView *popup in activePopups) { [self hidePopup:popup]; } } <...>
<...> - (PopupView *)popupFromRestorationID:(NSString *)restorationID { // .xib NSArray *allViews = [[NSBundle mainBundle] loadNibNamed:@"PopupView.xib" owner:self options:nil]; // for (PopupView *view in allViews) { // restorationIdentifier , , , if ([view.restorationIdentifier isEqualToString:restorationID]) { view.alpha = 0.0f; [self.delegate.view addSubview:view]; return view; } } // ! return nil; } - (void)showPopup:(PopupView *)popup { // innerPopupView 50% [popup.innerPopupView setTransform:CGAffineTransformMakeScale(0.5, 0.5)]; // [UIView animateWithDuration:0.2f animations:^{ // popup.alpha = 1.0f; // 100% [popup.innerPopupView setTransform:CGAffineTransformMakeScale(1.0, 1.0)]; }]; // [popup.backgroundView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissAllPopups)]]; // [activePopups addObject:popup]; } - (void)hidePopup:(UIView *)popup { // [UIView animateWithDuration:0.2f animations:^{ // popup.alpha = 0.0f; } completion:^(BOOL finished){ // ViewController'a [popup removeFromSuperview]; }]; // , [activePopups removeObject:popup]; } - (void)configurePopup:(PopupView *)popup forName:(NSString *)name { // popup.popupTitleLabel.text = @"Popup Title"; // popup.popupTextLabel.text = @"Hello World!"; // [self setTitle:@"Okay"]; } - (void)setTitle:(NSString *)title forButton:(UIButton *)button { [button setTitle:title forState:UIControlStateNormal]; [button setTitle:title forState:UIControlStateSelected]; [button setTitle:title forState:UIControlStateHighlighted]; [button setTitle:title forState:UIControlStateDisabled]; } @end
#import <Foundation/Foundation.h> @protocol PopupControllerDelegate @required - (void)touchedPopupButton:(UIButton *)sender; @end
[popupController showHelloWorldPopup];
- (void)touchedPopupButton:(UIButton *)sender { // [popupController dismissAllPopups]; }
Source: https://habr.com/ru/post/192100/
All Articles