GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - RajatJain4061/RKUserResizableView: RKUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS (Swift 3).

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
RKUserResizableViewDemo
RKUserResizableViewDemo
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
RKUserResizableView.swift
RKUserResizableView.swift
 
 
screenshot.png
screenshot.png
 
 

Repository files navigation

RKUserResizableView

RKUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS (Swift 3).

RKUserResizableView is a user-resizable, user-repositionable UIView subclass. It is modeled after the resizable image view from the Pages iOS app. Any UIView can be provided as the content view for the RKUserResizableView.

Screenshot

RKUserResizableViewScreenshot

How To Use It

Installation

Include RKUserResizableView.swift in your project.

Setting up the RKUserResizableView

You'll need to construct a new instance of RKUserResizableView. Then, set the contentView on the RKUserResizableView to the view you'd like the user to interact with.

     var currentlyEditingView:RKUserResizableView? = nil
     var lastEditedView:RKUserResizableView? = nil

     override func viewDidLoad() {
          super.viewDidLoad()

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

          // (2) Create a second resizable view with a UIImageView as the content.
          let imageFrame = CGRect(x: 50, y: 200, width: 200, height: 200)
          let imageResizableView = RKUserResizableView(frame: imageFrame)
          let imageView = UIImageView(image: UIImage(named: "smiley"))
          imageResizableView.contentView = imageView
          imageResizableView.delegate = self
          self.view.addSubview(imageResizableView)
     }

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

userResizableView.delegate = self;

Then implement the following delegate methods.

// Called when the resizable view receives touchesBegan: and activates the editing handles.
func userResizableViewDidBeginEditing(_ userResizableView: RKUserResizableView)

// Called when the resizable view receives touchesEnded: or touchesCancelled:
func userResizableViewDidEndEditing(_ userResizableView: RKUserResizableView)

By default, RKUserResizableView 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 RKUserResizableView is customizable using the following properties:

// Default is 48.0 for each.
var minWidth: CGFloat = 48.0
var minHeight: CGFloat = 48.0

// Defaults to YES. Disables the user from dragging the view outside the parent view's bounds.
var isPreventsPositionOutsideSuperview: Bool = true

For an example of how to use RKUserResizableView, please see the included example project.

Acknowledgments

  • Hat tip to Stephen Poletto spoletto

About

RKUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS (Swift 3).

Resources

Readme
MIT license
Activity

Stars

23 stars

Watchers

1 watching

Forks

6 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.