Coder Social home page Coder Social logo

yippeeapp / stpopup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevin-lyn/stpopup

0.0 3.0 0.0 144 KB

STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad.

License: MIT License

Ruby 2.55% Objective-C 97.45%

stpopup's Introduction

STPopup CI Status Version License

STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad.

Features:

  • Extend your view controller from UIViewController, build it in your familiar way.
  • Push/Pop view controller in to/out of popup view stack, and set navigation items by using self.navigationItem.leftBarButtonItem and rightBarButtonItem, just like you are using UINavigationController.
  • Customize UI by using UIAppearance.
  • Auto-reposition of popup view when keyboard is showing up, make sure your UITextField/UITextView won't be covered by the keyboard.
  • Drag navigation bar to dismiss popup view.
  • Support both portrait and landscape orientation, and both iPhone and iPad.

Overview

Used in Sth4Me app
Sth4Me

Get Started

platform :ios, '7.0'
pod 'STPopup'

Import header file

#import <STPopup/STPopup.h>

Initialize STPopupController

STPopupController *popupController = [[STPopupController alloc] initWithRootViewController:[ViewController new]];
[popupController presentInViewController:self];

Set content size in view controller

@implementation ViewController

- (instancetype)init
{
    if (self = [super init]) {
        self.title = @"View Controller";
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(nextBtnDidTap)];
        self.contentSizeInPopup = CGSizeMake(300, 400);
        self.landscapeContentSizeInPopup = CGSizeMake(400, 200);
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Add views here
    // self.view.frame.size == self.contentSizeInPopup in portrait
    // self.view.frame.size == self.landscapeContentSizeInPopup in landscape
}

@end

Push & Pop view controllers

[self.popupController pushViewController:[ViewController new] animated:YES];
[self.popupController popViewControllerAnimated:YES];

Push & Pop

Customize UI

[STPopupNavigationBar appearance].barTintColor = [UIColor colorWithRed:0.20 green:0.60 blue:0.86 alpha:1.0];
[STPopupNavigationBar appearance].tintColor = [UIColor whiteColor];
[STPopupNavigationBar appearance].barStyle = UIBarStyleDefault;
[STPopupNavigationBar appearance].titleTextAttributes = @{ NSFontAttributeName: [UIFont fontWithName:@"Cochin" size:18], NSForegroundColorAttributeName: [UIColor whiteColor] };
    
[[UIBarButtonItem appearanceWhenContainedIn:[STPopupNavigationBar class], nil] setTitleTextAttributes:@{ NSFontAttributeName:[UIFont fontWithName:@"Cochin" size:17] } forState:UIControlStateNormal];

Customize UI

Auto-reposition when keyboard is showing up
No codes needed for this feature
Auto-reposition

Drag to dismiss
No codes needed for this feature
Drag to dismiss

Handle orientation change
No codes needed for this feature
Orientation change

For more details, please download the example project.

stpopup's People

Contributors

kevin-lyn avatar

Watchers

Chew Chit Siang avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.