GithubHelp home page GithubHelp logo

irons163 / iruserresizableview-swift Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 126 KB

IRUserResizableView-swift is a powerful resizable view for iOS.

Swift 96.70% Objective-C 3.30%
ios swift resizeable resizeableview

iruserresizableview-swift's Introduction

Build Status Platform

IRUserResizableView-swift

  • IRUserResizableView-swift is a powerful resizable view for iOS.
  • IRUserResizableView-swift is modeled after the resizable image view from the Pages iOS app. Any UIView can be provided as the content view for the IRUserResizableView-swift. As the view is respositioned and resized, setFrame: will be called on the content view accordingly.
  • Objc version see here:IRUserResizableView

Features

  • Resizable.

Install

Git

  • Git clone this project.
  • Copy this project into your own project.
  • Add the .xcodeproj into you project and link it as embed framework.

Options

  • You can remove the demo and ScreenShots folder.

Cocoapods

  • Not support yet.

Usage

Basic

import IRUserResizableView_swift

...

override func viewDidLoad() {
    super.viewDidLoad()

    let appFrame = UIScreen.main.bounds
    self.view = UIView.init(frame: appFrame);
    self.view.backgroundColor = .green;

    // (1) Create a user resizable view with a simple red background content view.
    let gripFrame = CGRect.init(x: 50, y: 50, width: 200, height: 150)
    let userResizableView = IRUserResizableView.init(frame: gripFrame)
    let contentView = UIView.init(frame: gripFrame);
    contentView.backgroundColor = .red;
    userResizableView.contentView = contentView;
    userResizableView.delegate = self;
    userResizableView.showEditingHandles()
    self.view.addSubview(userResizableView)
}

If you'd like to receive callbacks when the IRUserResizableView-swift receives touchBegan:, touchesEnded: and touchesCancelled: messages, set the delegate on the IRUserResizableView-swift accordingly.

userResizableView.delegate = self

Then implement the following delegate methods.

func userResizableViewDidBeginEditing(userResizableView: IRUserResizableView)
func userResizableViewDidEndEditing(userResizableView: IRUserResizableView)

By default, IRUserResizableView-swift will show the editing handles (as seen in the screenshot above) whenever it receives a touch event. The editing handles will remain visible even after the userResizableViewDidEndEditing: message is sent. This is to provide visual feedback to the user that the view is indeed moveable and resizable. If you'd like to dismiss the editing handles, you must explicitly call -hideEditingHandles.

The IRUserResizableView-swift is customizable using the following properties:

var minWidth: CGFloat = 0.0
var minHeight: CGFloat = 0.0
var preventsPositionOutsideSuperview: Bool?

For an example of how to use IRUserResizableView-swift, please see the included example project.

Screenshots

Demo

Copyright

This project is inspired from SPUserResizableView.

iruserresizableview-swift's People

Contributors

irons163 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

devrezwan

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.