├── .gitignore ├── .swift-version ├── .travis.yml ├── Classes ├── OTGripPointView.swift └── OTResizableView.swift ├── DemoApplication ├── DemoApplication.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── DemoApplication │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController │ ├── ViewController.swift │ └── ViewController.xib ├── LICENSE ├── OTResizableView.podspec ├── OTResizableView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── OTResizableView.xcscheme ├── OTResizableView ├── Info.plist └── OTResizableView.h └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode (from gitignore.io) 2 | build/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | *.xccheckout 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | *.xcuserstate 18 | 19 | # CocoaPod 20 | Pods/* 21 | Podfile.lock 22 | 23 | # Carthage 24 | Carthage/Build 25 | 26 | # others 27 | *.swp 28 | !.gitkeep 29 | .DS_Store 30 | UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | xcode_project: OTResizableView.xcodeproj 4 | 5 | before_install: 6 | - gem install cocoapods -v '0.34.4' 7 | - pod install 8 | 9 | 10 | script: 11 | - xctool -workspace OTResizableView.xcworkspace -scheme OTResizableView -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO 12 | -------------------------------------------------------------------------------- /Classes/OTGripPointView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OTGripPointView.swift 3 | // OTResizableView 4 | // 5 | // Created by Tomosuke Okada on 2017/08/27. 6 | // Copyright © 2017年 TomosukeOkada. All rights reserved. 7 | // 8 | // https://github.com/PKPK-Carnage/OTResizableView 9 | 10 | /** 11 | [OTResizableView] 12 | 13 | Copyright (c) [2017] [Tomosuke Okada] 14 | 15 | This software is released under the MIT License. 16 | http://opensource.org/licenses/mit-license.ph 17 | 18 | */ 19 | 20 | import UIKit 21 | 22 | class OTGripPointView: UIView { 23 | 24 | var viewStrokeColor: UIColor? 25 | let viewStrokeLineWidth:CGFloat = 2 26 | 27 | var gripPointStrokeColor: UIColor? 28 | var gripPointFillColor: UIColor? 29 | 30 | let gripPointDiameter:CGFloat = 10 31 | let gripPointStrokeWidth:CGFloat = 2 32 | 33 | init() { 34 | super.init(frame: CGRect.zero) 35 | initialize() 36 | } 37 | 38 | 39 | override init(frame: CGRect) { 40 | super.init(frame: frame) 41 | initialize() 42 | } 43 | 44 | @available(*, unavailable) 45 | required init?(coder aDecoder: NSCoder) { 46 | fatalError("init(coder:) has not been implemented") 47 | } 48 | 49 | private func initialize() { 50 | backgroundColor = UIColor.clear 51 | } 52 | 53 | 54 | override func draw(_ rect: CGRect) { 55 | let strokeRect = rect.insetBy(dx: gripPointDiameter, dy: gripPointDiameter) 56 | draw(stroke: strokeRect, lineWidth: viewStrokeLineWidth, color: viewStrokeColor!) 57 | 58 | let leftX:CGFloat = gripPointDiameter/2 59 | let rightX:CGFloat = rect.size.width - gripPointDiameter - gripPointDiameter/2 60 | let upperY:CGFloat = gripPointDiameter/2 61 | let lowerY:CGFloat = rect.size.height - gripPointDiameter - gripPointDiameter/2 62 | 63 | let gripPointSize = CGSize(width: gripPointDiameter, height: gripPointDiameter) 64 | 65 | let upperLeft = CGRect(origin: CGPoint(x: leftX, y: upperY), size: gripPointSize) 66 | draw(circle: upperLeft, strokeWidth: gripPointStrokeWidth, strokeColor: gripPointStrokeColor!, fillColor: gripPointFillColor!) 67 | 68 | let upperRight = CGRect(origin: CGPoint(x: rightX, y: upperY), size: gripPointSize) 69 | draw(circle: upperRight, strokeWidth: gripPointStrokeWidth, strokeColor: gripPointStrokeColor!, fillColor: gripPointFillColor!) 70 | 71 | let lowerLeft = CGRect(origin: CGPoint(x: leftX, y: lowerY), size:gripPointSize) 72 | draw(circle: lowerLeft, strokeWidth: gripPointStrokeWidth, strokeColor: gripPointStrokeColor!, fillColor: gripPointFillColor!) 73 | 74 | let lowerRight = CGRect(origin: CGPoint(x: rightX, y: lowerY), size:gripPointSize) 75 | draw(circle: lowerRight, strokeWidth: gripPointStrokeWidth, strokeColor: gripPointStrokeColor!, fillColor: gripPointFillColor!) 76 | } 77 | 78 | 79 | private func draw(stroke rect:CGRect,lineWidth:CGFloat,color:UIColor) { 80 | let strokePath = UIBezierPath(rect: rect) 81 | strokePath.lineWidth = lineWidth; 82 | 83 | color.setStroke() 84 | 85 | strokePath.stroke() 86 | } 87 | 88 | 89 | private func draw(circle rect: CGRect, strokeWidth: CGFloat, strokeColor: UIColor, fillColor: UIColor) { 90 | let circlePath = UIBezierPath(ovalIn: rect) 91 | circlePath.lineWidth = strokeWidth 92 | 93 | strokeColor.setStroke() 94 | fillColor.setFill() 95 | 96 | circlePath.fill() 97 | circlePath.stroke() 98 | } 99 | 100 | 101 | } 102 | -------------------------------------------------------------------------------- /Classes/OTResizableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OTResizableView.swift 3 | // OTResizableView 4 | // 5 | // Created by Tomosuke Okada on 2017/08/27. 6 | // Copyright © 2017年 TomosukeOkada. All rights reserved. 7 | // 8 | // https://github.com/PKPK-Carnage/OTResizableView 9 | 10 | /** 11 | [OTResizableView] 12 | 13 | Copyright (c) [2017] [Tomosuke Okada] 14 | 15 | This software is released under the MIT License. 16 | http://opensource.org/licenses/mit-license.ph 17 | 18 | */ 19 | 20 | import UIKit 21 | 22 | @objc public enum TappedPosition: Int { 23 | case UpperLeft 24 | case UpperRight 25 | case LowerLeft 26 | case LowerRight 27 | case Center 28 | case None 29 | } 30 | 31 | 32 | @objc public protocol OTResizableViewDelegate: class { 33 | 34 | @objc optional func tapBegin(_ resizableView:OTResizableView) 35 | 36 | @objc optional func tapChanged(_ resizableView:OTResizableView) 37 | 38 | @objc optional func tapMoved(_ resizableView:OTResizableView) 39 | 40 | @objc optional func tapEnd(_ resizableView:OTResizableView) 41 | 42 | } 43 | 44 | 45 | @objc open class OTResizableView: UIView, UIGestureRecognizerDelegate { 46 | 47 | @objc public weak var delegate: OTResizableViewDelegate? 48 | 49 | @objc public var minimumWidth: CGFloat = 100 { 50 | didSet { 51 | if keepAspectEnabled { 52 | minimumWidth = oldValue 53 | } 54 | } 55 | } 56 | 57 | @objc public var minimumHeight: CGFloat = 100 { 58 | didSet { 59 | if keepAspectEnabled { 60 | minimumHeight = oldValue 61 | } 62 | } 63 | } 64 | 65 | @objc public var keepAspectEnabled = false { 66 | willSet { 67 | if newValue { 68 | minimumWidth = frame.width * minimumAspectScale 69 | minimumHeight = frame.height * minimumAspectScale 70 | } 71 | } 72 | } 73 | 74 | @objc open var minimumAspectScale: CGFloat = 1 75 | 76 | @objc open var resizeEnabled = false { 77 | didSet { 78 | gripPointView.isHidden = resizeEnabled ? false:true 79 | } 80 | } 81 | 82 | @objc open var viewStrokeColor = UIColor.red { 83 | didSet { 84 | gripPointView.viewStrokeColor = viewStrokeColor 85 | } 86 | } 87 | 88 | @objc open var gripPointStrokeColor = UIColor.white { 89 | didSet{ 90 | gripPointView.gripPointStrokeColor = gripPointStrokeColor 91 | } 92 | } 93 | 94 | @objc open var gripPointFillColor = UIColor.blue { 95 | didSet { 96 | gripPointView.gripPointFillColor = gripPointFillColor 97 | } 98 | } 99 | 100 | @objc open var gripTappableSize: CGFloat = 40 101 | 102 | @objc public let gripPointDiameter: CGFloat = 10 103 | 104 | @objc public private(set) var contentView = UIView() 105 | 106 | @objc public private(set) var currentTappedPostion:TappedPosition = .None 107 | 108 | private var startFrame = CGRect.zero 109 | private var minimumPoint = CGPoint.zero 110 | 111 | private var touchStartPointInSuperview = CGPoint.zero 112 | private var touchStartPointInSelf = CGPoint.zero 113 | 114 | private var maxAspectFrame = CGRect.zero 115 | 116 | private var gripPointView = OTGripPointView() 117 | 118 | //MARK: - Initialize 119 | public init(contentView: UIView) { 120 | super.init(frame: contentView.frame.insetBy(dx: -gripPointDiameter, dy: -gripPointDiameter)) 121 | 122 | initialize() 123 | 124 | setContentView(newContentView: contentView) 125 | } 126 | 127 | 128 | @available(*, unavailable) 129 | required public init?(coder aDecoder: NSCoder) { 130 | fatalError("init(coder:) has not been implemented") 131 | } 132 | 133 | 134 | private func initialize() { 135 | backgroundColor = UIColor.clear 136 | prepareGesture() 137 | } 138 | 139 | 140 | //MARK: - LifeCycle 141 | override open func willMove(toSuperview newSuperview: UIView?) { 142 | super.willMove(toSuperview: newSuperview) 143 | 144 | prepareGripPointView() 145 | } 146 | 147 | 148 | //MARK: - Prepare 149 | private func prepareGesture() { 150 | let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap(gesture:))) 151 | addGestureRecognizer(tapGestureRecognizer) 152 | 153 | 154 | let panGesutureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePan(gesture:))) 155 | addGestureRecognizer(panGesutureRecognizer) 156 | } 157 | 158 | 159 | private func prepareGripPointView() { 160 | gripPointView.removeFromSuperview() 161 | 162 | gripPointView = OTGripPointView(frame: bounds) 163 | gripPointView.isHidden = true 164 | 165 | gripPointView.viewStrokeColor = viewStrokeColor 166 | gripPointView.gripPointStrokeColor = gripPointStrokeColor 167 | gripPointView.gripPointFillColor = gripPointFillColor 168 | 169 | addSubview(gripPointView) 170 | } 171 | 172 | 173 | //MARK: - Set 174 | private func setContentView(newContentView: UIView) { 175 | contentView.removeFromSuperview() 176 | contentView = newContentView; 177 | contentView.frame.origin = CGPoint(x: gripPointDiameter, y: gripPointDiameter) 178 | addSubview(contentView) 179 | 180 | gripPointView.removeFromSuperview() 181 | addSubview(gripPointView) 182 | } 183 | 184 | 185 | @objc public func setResizedFrame(newFrame: CGRect) { 186 | super.frame = newFrame 187 | contentView.frame = bounds.insetBy(dx: gripPointDiameter, dy: gripPointDiameter) 188 | contentView.setNeedsDisplay() 189 | gripPointView.frame = bounds 190 | gripPointView.setNeedsDisplay() 191 | } 192 | 193 | 194 | //MARK: - Gesture 195 | @objc open func handleTap(gesture: UITapGestureRecognizer) { 196 | delegate?.tapBegin?(self) 197 | } 198 | 199 | 200 | @objc open func handlePan(gesture: UIPanGestureRecognizer) { 201 | switch gesture.state { 202 | case .began: 203 | if resizeEnabled { 204 | 205 | startFrame = frame; 206 | 207 | touchStartPointInSuperview = gesture.location(in: superview) 208 | touchStartPointInSelf = gesture.location(in: self) 209 | 210 | currentTappedPostion = detectCurrentTappedPosition() 211 | 212 | 213 | switch currentTappedPostion { 214 | case .UpperLeft, .UpperRight, .LowerLeft, .LowerRight: 215 | minimumPoint = measureMinimumPoint() 216 | 217 | if keepAspectEnabled { 218 | maxAspectFrame = measureMaximumKeepAspectFrame() 219 | } 220 | 221 | case .Center: 222 | break 223 | 224 | case .None: 225 | break 226 | } 227 | } 228 | case .changed: 229 | if resizeEnabled { 230 | switch currentTappedPostion { 231 | case .UpperLeft, .UpperRight, .LowerLeft, .LowerRight: 232 | 233 | let currentTouchPointInSuperview = gesture.location(in: superview) 234 | 235 | var resizedRect = CGRect.zero 236 | 237 | if keepAspectEnabled { 238 | resizedRect = generateKeepAspectFrame(position: currentTappedPostion, currentTouchPoint: currentTouchPointInSuperview) 239 | resizedRect = adjustKeepAspect(rect: resizedRect) 240 | } else { 241 | let differenceX = currentTouchPointInSuperview.x - touchStartPointInSuperview.x 242 | let differenceY = currentTouchPointInSuperview.y - touchStartPointInSuperview.y 243 | 244 | resizedRect = generateNormalFrame(position: currentTappedPostion, differenceX: differenceX, differenceY: differenceY) 245 | resizedRect = adjustNormal(rect: resizedRect) 246 | } 247 | 248 | setResizedFrame(newFrame: resizedRect) 249 | 250 | delegate?.tapChanged?(self) 251 | 252 | case .Center: 253 | 254 | let currentTouchPointInSelf = gesture.location(in: self) 255 | 256 | moveView(touchPoint: currentTouchPointInSelf, startPoint: touchStartPointInSelf) 257 | 258 | delegate?.tapMoved?(self) 259 | 260 | case .None: 261 | return 262 | } 263 | } 264 | case .ended: 265 | 266 | currentTappedPostion = .None 267 | 268 | maxAspectFrame = CGRect.zero 269 | 270 | delegate?.tapEnd?(self) 271 | 272 | case .cancelled: 273 | 274 | currentTappedPostion = .None 275 | 276 | maxAspectFrame = CGRect.zero 277 | 278 | delegate?.tapEnd?(self) 279 | 280 | default: 281 | 282 | currentTappedPostion = .None 283 | 284 | maxAspectFrame = CGRect.zero 285 | 286 | return 287 | } 288 | } 289 | 290 | 291 | //MARK: - Normal resize 292 | private func generateNormalFrame(position:TappedPosition, differenceX: CGFloat, differenceY: CGFloat) -> CGRect { 293 | 294 | let startX = startFrame.origin.x 295 | let startY = startFrame.origin.y 296 | let startWidth = startFrame.width 297 | let startHeight = startFrame.height 298 | 299 | switch position { 300 | case .UpperLeft: 301 | return CGRect(x: startX + differenceX, y: startY + differenceY, width: startWidth - differenceX, height: startHeight - differenceY) 302 | case .UpperRight: 303 | return CGRect(x: startX, y: startY + differenceY, width: startWidth + differenceX, height: startHeight - differenceY) 304 | case .LowerLeft: 305 | return CGRect(x: startX + differenceX, y: startY, width: startWidth - differenceX, height: startHeight + differenceY) 306 | case .LowerRight: 307 | return CGRect(x: startX, y: startY, width: startWidth + differenceX, height: startHeight + differenceY) 308 | default: 309 | return CGRect.zero 310 | } 311 | } 312 | 313 | private func adjustNormal(rect: CGRect) -> CGRect { 314 | guard let superview = superview else { 315 | return CGRect.zero 316 | } 317 | 318 | var x = rect.origin.x 319 | var y = rect.origin.y 320 | var width = rect.size.width 321 | var height = rect.size.height 322 | 323 | if x < superview.bounds.origin.x { 324 | let deltaW = frame.origin.x - superview.bounds.origin.x 325 | width = frame.size.width + deltaW 326 | x = superview.bounds.origin.x 327 | } 328 | 329 | if rect.origin.x + width > superview.bounds.origin.x + superview.bounds.size.width { 330 | width = superview.bounds.size.width - x 331 | } 332 | 333 | if y < superview.bounds.origin.y { 334 | let deltaH = frame.origin.y - superview.bounds.origin.y 335 | height = frame.size.height + deltaH 336 | y = superview.bounds.origin.y 337 | } 338 | 339 | if y + height > superview.bounds.origin.y + superview.bounds.size.height { 340 | height = superview.bounds.size.height - y 341 | } 342 | 343 | if width <= minimumWidth { 344 | width = minimumWidth 345 | x = minimumPoint.x 346 | } 347 | 348 | if height <= minimumHeight { 349 | height = minimumHeight 350 | y = minimumPoint.y 351 | } 352 | 353 | return CGRect(x: x, y: y, width: width, height: height) 354 | } 355 | 356 | 357 | //MARK: - Keep Aspect resize 358 | private func generateKeepAspectFrame(position:TappedPosition, currentTouchPoint: CGPoint) -> CGRect { 359 | 360 | let scaleTuple = generateScale(position: position, currentTouchPoint: currentTouchPoint) 361 | let widthScale = scaleTuple.widthScale 362 | let heightScale = scaleTuple.heightScale 363 | 364 | var width: CGFloat = 0 365 | var height: CGFloat = 0 366 | 367 | if widthScale > heightScale { 368 | width = startFrame.width * widthScale 369 | height = startFrame.height * widthScale 370 | } else { 371 | width = startFrame.width * heightScale 372 | height = startFrame.height * heightScale 373 | } 374 | 375 | let differenceX = startFrame.width - width 376 | let differenceY = startFrame.height - height 377 | 378 | switch position { 379 | case .UpperLeft: 380 | return CGRect(x: startFrame.origin.x + differenceX, y: startFrame.origin.y + differenceY, width: width, height: height) 381 | case .UpperRight: 382 | return CGRect(x: startFrame.origin.x, y: startFrame.origin.y + differenceY , width: width, height: height) 383 | case .LowerLeft: 384 | return CGRect(x: startFrame.origin.x + differenceX, y: startFrame.origin.y, width: width, height: height) 385 | case .LowerRight: 386 | return CGRect(x: startFrame.origin.x, y: startFrame.origin.y, width: width, height: height) 387 | default: 388 | return CGRect.zero 389 | } 390 | 391 | } 392 | 393 | 394 | private func generateScale(position:TappedPosition, currentTouchPoint: CGPoint) -> (widthScale: CGFloat, heightScale: CGFloat) { 395 | switch position { 396 | case .UpperLeft: 397 | return (widthScale: (startFrame.origin.x - currentTouchPoint.x + startFrame.width) / startFrame.width, 398 | heightScale: (startFrame.origin.y - currentTouchPoint.y + startFrame.height) / startFrame.height) 399 | case .UpperRight: 400 | return (widthScale: (currentTouchPoint.x - startFrame.origin.x) / startFrame.width, 401 | heightScale: (startFrame.origin.y - currentTouchPoint.y + startFrame.height) / startFrame.height) 402 | case .LowerLeft: 403 | return (widthScale: (startFrame.origin.x - currentTouchPoint.x + startFrame.width) / startFrame.width, 404 | heightScale: (currentTouchPoint.y - startFrame.origin.y) / startFrame.height) 405 | case .LowerRight: 406 | return (widthScale: (currentTouchPoint.x - startFrame.origin.x) / startFrame.width, 407 | heightScale: (currentTouchPoint.y - startFrame.origin.y) / startFrame.width) 408 | default: 409 | return (widthScale: 0, heightScale: 0) 410 | } 411 | } 412 | 413 | 414 | private func adjustKeepAspect(rect: CGRect) -> CGRect{ 415 | 416 | guard let superview = superview else { 417 | return CGRect.zero 418 | } 419 | 420 | var x = rect.origin.x 421 | var y = rect.origin.y 422 | var width = rect.size.width 423 | var height = rect.size.height 424 | 425 | if x < superview.bounds.origin.x { 426 | if currentTappedPostion == .UpperLeft || currentTappedPostion == .LowerLeft { 427 | return maxAspectFrame 428 | } 429 | } 430 | 431 | if x + width > superview.bounds.origin.x + superview.bounds.size.width { 432 | if currentTappedPostion == .UpperRight || currentTappedPostion == .LowerRight { 433 | return maxAspectFrame 434 | } 435 | } 436 | 437 | if y < superview.bounds.origin.y { 438 | if currentTappedPostion == .UpperLeft || currentTappedPostion == .UpperRight { 439 | return maxAspectFrame 440 | } 441 | } 442 | 443 | if y + height > superview.bounds.origin.y + superview.bounds.size.height { 444 | if currentTappedPostion == .LowerLeft || currentTappedPostion == .LowerRight { 445 | return maxAspectFrame 446 | } 447 | } 448 | 449 | if width <= minimumWidth { 450 | width = minimumWidth 451 | x = minimumPoint.x 452 | } 453 | 454 | if height <= minimumHeight { 455 | height = minimumHeight 456 | y = minimumPoint.y 457 | } 458 | 459 | return CGRect(x: x, y: y, width: width, height: height) 460 | } 461 | 462 | 463 | //MARK: - Prepare TapChanged 464 | private func detectCurrentTappedPosition() -> TappedPosition { 465 | if touchStartPointInSelf.x < gripTappableSize && touchStartPointInSelf.y < gripTappableSize { 466 | 467 | return .UpperLeft 468 | 469 | } else if bounds.size.width - touchStartPointInSelf.x < gripTappableSize && touchStartPointInSelf.y < gripTappableSize { 470 | 471 | return .UpperRight 472 | 473 | } else if touchStartPointInSelf.x < gripTappableSize && bounds.size.height - touchStartPointInSelf.y < gripTappableSize { 474 | 475 | return .LowerLeft 476 | 477 | } else if bounds.size.width - touchStartPointInSelf.x < gripTappableSize && bounds.size.height - touchStartPointInSelf.y < gripTappableSize { 478 | 479 | return .LowerRight 480 | 481 | } else { 482 | 483 | return .Center 484 | 485 | } 486 | } 487 | 488 | 489 | private func measureMinimumPoint() -> CGPoint { 490 | let originX = startFrame.origin.x 491 | let originY = startFrame.origin.y 492 | 493 | let upperRightX = originX + startFrame.size.width 494 | let lowerLeftY = originY + startFrame.size.height 495 | 496 | switch currentTappedPostion { 497 | 498 | case .UpperLeft: 499 | 500 | return CGPoint(x: upperRightX - minimumWidth, y: lowerLeftY - minimumHeight) 501 | 502 | case .UpperRight: 503 | 504 | return CGPoint(x: originX, y: lowerLeftY - minimumHeight) 505 | 506 | case .LowerLeft: 507 | 508 | return CGPoint(x: upperRightX - minimumWidth, y: originY) 509 | 510 | case .LowerRight: 511 | 512 | return CGPoint(x: originX, y: originY) 513 | 514 | default: 515 | 516 | return CGPoint.zero 517 | } 518 | } 519 | 520 | 521 | private func measureMaximumKeepAspectFrame() -> CGRect { 522 | guard let superview = superview else { 523 | return CGRect.zero 524 | } 525 | 526 | var xMaxFrame = CGRect.zero 527 | var yMaxFrame = CGRect.zero 528 | 529 | switch currentTappedPostion { 530 | case .UpperLeft: 531 | 532 | xMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 533 | currentTouchPoint: CGPoint(x: superview.bounds.origin.x, y: frame.origin.y)) 534 | 535 | yMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 536 | currentTouchPoint: CGPoint(x: frame.origin.x, y: superview.bounds.origin.y)) 537 | 538 | case .UpperRight: 539 | 540 | xMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 541 | currentTouchPoint: CGPoint(x: superview.bounds.width, y: frame.origin.y)) 542 | 543 | yMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 544 | currentTouchPoint: CGPoint(x: frame.origin.x + frame.width, y: superview.bounds.origin.y)) 545 | 546 | case .LowerLeft: 547 | 548 | xMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 549 | currentTouchPoint: CGPoint(x: superview.bounds.origin.x, y: frame.origin.y + frame.height)) 550 | 551 | yMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 552 | currentTouchPoint: CGPoint(x: frame.origin.x, y: superview.bounds.height)) 553 | 554 | case .LowerRight: 555 | 556 | xMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 557 | currentTouchPoint: CGPoint(x: superview.bounds.width, y: frame.origin.y + frame.height)) 558 | 559 | yMaxFrame = generateKeepAspectFrame(position: currentTappedPostion, 560 | currentTouchPoint: CGPoint(x: frame.origin.x + frame.width, y: superview.bounds.height)) 561 | 562 | default: 563 | 564 | break 565 | } 566 | 567 | return xMaxFrame.width/frame.width < yMaxFrame.width/frame.width ? xMaxFrame : yMaxFrame 568 | 569 | } 570 | 571 | 572 | private func moveView(touchPoint: CGPoint, startPoint: CGPoint) { 573 | var newCenter = CGPoint(x: center.x + touchPoint.x - startPoint.x, y: center.y + touchPoint.y - startPoint.y) 574 | 575 | let midPointX = bounds.midX 576 | 577 | if newCenter.x > superview!.bounds.size.width - midPointX { 578 | newCenter.x = superview!.bounds.size.width - midPointX; 579 | } 580 | 581 | if newCenter.x < midPointX { 582 | newCenter.x = midPointX; 583 | } 584 | 585 | let midPointY = bounds.midY 586 | 587 | if newCenter.y > superview!.bounds.size.height - midPointY { 588 | newCenter.y = superview!.bounds.size.height - midPointY; 589 | } 590 | 591 | if newCenter.y < midPointY { 592 | newCenter.y = midPointY; 593 | } 594 | 595 | center = newCenter; 596 | } 597 | } 598 | 599 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0430C1251F524ACB00860C50 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430C1241F524ACB00860C50 /* AppDelegate.swift */; }; 11 | 0430C12A1F524ACC00860C50 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0430C1281F524ACC00860C50 /* Main.storyboard */; }; 12 | 0430C12C1F524ACD00860C50 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0430C12B1F524ACD00860C50 /* Assets.xcassets */; }; 13 | 0430C12F1F524ACD00860C50 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0430C12D1F524ACD00860C50 /* LaunchScreen.storyboard */; }; 14 | 0430C13C1F524B0F00860C50 /* OTResizableView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0430C13B1F524AF100860C50 /* OTResizableView.framework */; }; 15 | 0430C13D1F524B0F00860C50 /* OTResizableView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0430C13B1F524AF100860C50 /* OTResizableView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 16 | 0430C1461F524CAC00860C50 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430C1441F524CAC00860C50 /* ViewController.swift */; }; 17 | 0430C1471F524CAC00860C50 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0430C1451F524CAC00860C50 /* ViewController.xib */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 0430C13A1F524AF100860C50 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 0430C1361F524AF100860C50 /* OTResizableView.xcodeproj */; 24 | proxyType = 2; 25 | remoteGlobalIDString = 0430C1041F52499C00860C50; 26 | remoteInfo = OTResizableView; 27 | }; 28 | 0430C13E1F524B0F00860C50 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 0430C1361F524AF100860C50 /* OTResizableView.xcodeproj */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 0430C1031F52499C00860C50; 33 | remoteInfo = OTResizableView; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXCopyFilesBuildPhase section */ 38 | 0430C1401F524B1000860C50 /* Embed Frameworks */ = { 39 | isa = PBXCopyFilesBuildPhase; 40 | buildActionMask = 2147483647; 41 | dstPath = ""; 42 | dstSubfolderSpec = 10; 43 | files = ( 44 | 0430C13D1F524B0F00860C50 /* OTResizableView.framework in Embed Frameworks */, 45 | ); 46 | name = "Embed Frameworks"; 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXCopyFilesBuildPhase section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | 0430C1211F524ACB00860C50 /* DemoApplication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DemoApplication.app; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 0430C1241F524ACB00860C50 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 54 | 0430C1291F524ACC00860C50 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 55 | 0430C12B1F524ACD00860C50 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 56 | 0430C12E1F524ACD00860C50 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 57 | 0430C1301F524ACE00860C50 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 0430C1361F524AF100860C50 /* OTResizableView.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OTResizableView.xcodeproj; path = ../OTResizableView.xcodeproj; sourceTree = ""; }; 59 | 0430C1441F524CAC00860C50 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewController.swift; path = ViewController/ViewController.swift; sourceTree = ""; }; 60 | 0430C1451F524CAC00860C50 /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ViewController.xib; path = ViewController/ViewController.xib; sourceTree = ""; }; 61 | /* End PBXFileReference section */ 62 | 63 | /* Begin PBXFrameworksBuildPhase section */ 64 | 0430C11E1F524ACA00860C50 /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | 0430C13C1F524B0F00860C50 /* OTResizableView.framework in Frameworks */, 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | 0430C1181F524ACA00860C50 = { 76 | isa = PBXGroup; 77 | children = ( 78 | 0430C1231F524ACB00860C50 /* DemoApplication */, 79 | 0430C1221F524ACB00860C50 /* Products */, 80 | 0430C1361F524AF100860C50 /* OTResizableView.xcodeproj */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | 0430C1221F524ACB00860C50 /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 0430C1211F524ACB00860C50 /* DemoApplication.app */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | 0430C1231F524ACB00860C50 /* DemoApplication */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 0430C1241F524ACB00860C50 /* AppDelegate.swift */, 96 | 0430C1431F524C8700860C50 /* ViewController */, 97 | 0430C1281F524ACC00860C50 /* Main.storyboard */, 98 | 0430C12B1F524ACD00860C50 /* Assets.xcassets */, 99 | 0430C12D1F524ACD00860C50 /* LaunchScreen.storyboard */, 100 | 0430C1301F524ACE00860C50 /* Info.plist */, 101 | ); 102 | path = DemoApplication; 103 | sourceTree = ""; 104 | }; 105 | 0430C1371F524AF100860C50 /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 0430C13B1F524AF100860C50 /* OTResizableView.framework */, 109 | ); 110 | name = Products; 111 | sourceTree = ""; 112 | }; 113 | 0430C1431F524C8700860C50 /* ViewController */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 0430C1441F524CAC00860C50 /* ViewController.swift */, 117 | 0430C1451F524CAC00860C50 /* ViewController.xib */, 118 | ); 119 | name = ViewController; 120 | sourceTree = ""; 121 | }; 122 | /* End PBXGroup section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 0430C1201F524ACA00860C50 /* DemoApplication */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 0430C1331F524ACE00860C50 /* Build configuration list for PBXNativeTarget "DemoApplication" */; 128 | buildPhases = ( 129 | 0430C11D1F524ACA00860C50 /* Sources */, 130 | 0430C11E1F524ACA00860C50 /* Frameworks */, 131 | 0430C11F1F524ACA00860C50 /* Resources */, 132 | 0430C1401F524B1000860C50 /* Embed Frameworks */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | 0430C13F1F524B0F00860C50 /* PBXTargetDependency */, 138 | ); 139 | name = DemoApplication; 140 | productName = DemoApplication; 141 | productReference = 0430C1211F524ACB00860C50 /* DemoApplication.app */; 142 | productType = "com.apple.product-type.application"; 143 | }; 144 | /* End PBXNativeTarget section */ 145 | 146 | /* Begin PBXProject section */ 147 | 0430C1191F524ACA00860C50 /* Project object */ = { 148 | isa = PBXProject; 149 | attributes = { 150 | LastSwiftUpdateCheck = 0830; 151 | LastUpgradeCheck = 0900; 152 | ORGANIZATIONNAME = TomosukeOkada; 153 | TargetAttributes = { 154 | 0430C1201F524ACA00860C50 = { 155 | CreatedOnToolsVersion = 8.3.3; 156 | LastSwiftMigration = 0900; 157 | ProvisioningStyle = Automatic; 158 | }; 159 | }; 160 | }; 161 | buildConfigurationList = 0430C11C1F524ACA00860C50 /* Build configuration list for PBXProject "DemoApplication" */; 162 | compatibilityVersion = "Xcode 8.0"; 163 | developmentRegion = English; 164 | hasScannedForEncodings = 0; 165 | knownRegions = ( 166 | en, 167 | Base, 168 | ); 169 | mainGroup = 0430C1181F524ACA00860C50; 170 | productRefGroup = 0430C1221F524ACB00860C50 /* Products */; 171 | projectDirPath = ""; 172 | projectReferences = ( 173 | { 174 | ProductGroup = 0430C1371F524AF100860C50 /* Products */; 175 | ProjectRef = 0430C1361F524AF100860C50 /* OTResizableView.xcodeproj */; 176 | }, 177 | ); 178 | projectRoot = ""; 179 | targets = ( 180 | 0430C1201F524ACA00860C50 /* DemoApplication */, 181 | ); 182 | }; 183 | /* End PBXProject section */ 184 | 185 | /* Begin PBXReferenceProxy section */ 186 | 0430C13B1F524AF100860C50 /* OTResizableView.framework */ = { 187 | isa = PBXReferenceProxy; 188 | fileType = wrapper.framework; 189 | path = OTResizableView.framework; 190 | remoteRef = 0430C13A1F524AF100860C50 /* PBXContainerItemProxy */; 191 | sourceTree = BUILT_PRODUCTS_DIR; 192 | }; 193 | /* End PBXReferenceProxy section */ 194 | 195 | /* Begin PBXResourcesBuildPhase section */ 196 | 0430C11F1F524ACA00860C50 /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | 0430C12F1F524ACD00860C50 /* LaunchScreen.storyboard in Resources */, 201 | 0430C12C1F524ACD00860C50 /* Assets.xcassets in Resources */, 202 | 0430C1471F524CAC00860C50 /* ViewController.xib in Resources */, 203 | 0430C12A1F524ACC00860C50 /* Main.storyboard in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | 0430C11D1F524ACA00860C50 /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 0430C1461F524CAC00860C50 /* ViewController.swift in Sources */, 215 | 0430C1251F524ACB00860C50 /* AppDelegate.swift in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXSourcesBuildPhase section */ 220 | 221 | /* Begin PBXTargetDependency section */ 222 | 0430C13F1F524B0F00860C50 /* PBXTargetDependency */ = { 223 | isa = PBXTargetDependency; 224 | name = OTResizableView; 225 | targetProxy = 0430C13E1F524B0F00860C50 /* PBXContainerItemProxy */; 226 | }; 227 | /* End PBXTargetDependency section */ 228 | 229 | /* Begin PBXVariantGroup section */ 230 | 0430C1281F524ACC00860C50 /* Main.storyboard */ = { 231 | isa = PBXVariantGroup; 232 | children = ( 233 | 0430C1291F524ACC00860C50 /* Base */, 234 | ); 235 | name = Main.storyboard; 236 | sourceTree = ""; 237 | }; 238 | 0430C12D1F524ACD00860C50 /* LaunchScreen.storyboard */ = { 239 | isa = PBXVariantGroup; 240 | children = ( 241 | 0430C12E1F524ACD00860C50 /* Base */, 242 | ); 243 | name = LaunchScreen.storyboard; 244 | sourceTree = ""; 245 | }; 246 | /* End PBXVariantGroup section */ 247 | 248 | /* Begin XCBuildConfiguration section */ 249 | 0430C1311F524ACE00860C50 /* Debug */ = { 250 | isa = XCBuildConfiguration; 251 | buildSettings = { 252 | ALWAYS_SEARCH_USER_PATHS = NO; 253 | CLANG_ANALYZER_NONNULL = YES; 254 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 260 | CLANG_WARN_BOOL_CONVERSION = YES; 261 | CLANG_WARN_COMMA = YES; 262 | CLANG_WARN_CONSTANT_CONVERSION = YES; 263 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 264 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 265 | CLANG_WARN_EMPTY_BODY = YES; 266 | CLANG_WARN_ENUM_CONVERSION = YES; 267 | CLANG_WARN_INFINITE_RECURSION = YES; 268 | CLANG_WARN_INT_CONVERSION = YES; 269 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 272 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 273 | CLANG_WARN_STRICT_PROTOTYPES = YES; 274 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 278 | COPY_PHASE_STRIP = NO; 279 | DEBUG_INFORMATION_FORMAT = dwarf; 280 | ENABLE_STRICT_OBJC_MSGSEND = YES; 281 | ENABLE_TESTABILITY = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu99; 283 | GCC_DYNAMIC_NO_PIC = NO; 284 | GCC_NO_COMMON_BLOCKS = YES; 285 | GCC_OPTIMIZATION_LEVEL = 0; 286 | GCC_PREPROCESSOR_DEFINITIONS = ( 287 | "DEBUG=1", 288 | "$(inherited)", 289 | ); 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 297 | MTL_ENABLE_DEBUG_INFO = YES; 298 | ONLY_ACTIVE_ARCH = YES; 299 | SDKROOT = iphoneos; 300 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 301 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 302 | TARGETED_DEVICE_FAMILY = "1,2"; 303 | }; 304 | name = Debug; 305 | }; 306 | 0430C1321F524ACE00860C50 /* Release */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_ANALYZER_NONNULL = YES; 311 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 312 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 313 | CLANG_CXX_LIBRARY = "libc++"; 314 | CLANG_ENABLE_MODULES = YES; 315 | CLANG_ENABLE_OBJC_ARC = YES; 316 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 317 | CLANG_WARN_BOOL_CONVERSION = YES; 318 | CLANG_WARN_COMMA = YES; 319 | CLANG_WARN_CONSTANT_CONVERSION = YES; 320 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 321 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 322 | CLANG_WARN_EMPTY_BODY = YES; 323 | CLANG_WARN_ENUM_CONVERSION = YES; 324 | CLANG_WARN_INFINITE_RECURSION = YES; 325 | CLANG_WARN_INT_CONVERSION = YES; 326 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 327 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 330 | CLANG_WARN_STRICT_PROTOTYPES = YES; 331 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 332 | CLANG_WARN_UNREACHABLE_CODE = YES; 333 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 334 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 335 | COPY_PHASE_STRIP = NO; 336 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 337 | ENABLE_NS_ASSERTIONS = NO; 338 | ENABLE_STRICT_OBJC_MSGSEND = YES; 339 | GCC_C_LANGUAGE_STANDARD = gnu99; 340 | GCC_NO_COMMON_BLOCKS = YES; 341 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 342 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 343 | GCC_WARN_UNDECLARED_SELECTOR = YES; 344 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 345 | GCC_WARN_UNUSED_FUNCTION = YES; 346 | GCC_WARN_UNUSED_VARIABLE = YES; 347 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 348 | MTL_ENABLE_DEBUG_INFO = NO; 349 | SDKROOT = iphoneos; 350 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 351 | TARGETED_DEVICE_FAMILY = "1,2"; 352 | VALIDATE_PRODUCT = YES; 353 | }; 354 | name = Release; 355 | }; 356 | 0430C1341F524ACE00860C50 /* Debug */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 360 | CODE_SIGN_IDENTITY = "iPhone Developer"; 361 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 362 | CODE_SIGN_STYLE = Automatic; 363 | DEVELOPMENT_TEAM = NG4PAUE398; 364 | INFOPLIST_FILE = DemoApplication/Info.plist; 365 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 366 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 367 | PRODUCT_BUNDLE_IDENTIFIER = TomosukeOkada.OTResizableView.DemoApplication; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | PROVISIONING_PROFILE_SPECIFIER = ""; 370 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 371 | SWIFT_VERSION = 4.0; 372 | }; 373 | name = Debug; 374 | }; 375 | 0430C1351F524ACE00860C50 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 379 | CODE_SIGN_IDENTITY = "iPhone Developer"; 380 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 381 | CODE_SIGN_STYLE = Automatic; 382 | DEVELOPMENT_TEAM = NG4PAUE398; 383 | INFOPLIST_FILE = DemoApplication/Info.plist; 384 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 386 | PRODUCT_BUNDLE_IDENTIFIER = TomosukeOkada.OTResizableView.DemoApplication; 387 | PRODUCT_NAME = "$(TARGET_NAME)"; 388 | PROVISIONING_PROFILE_SPECIFIER = ""; 389 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 390 | SWIFT_VERSION = 4.0; 391 | }; 392 | name = Release; 393 | }; 394 | /* End XCBuildConfiguration section */ 395 | 396 | /* Begin XCConfigurationList section */ 397 | 0430C11C1F524ACA00860C50 /* Build configuration list for PBXProject "DemoApplication" */ = { 398 | isa = XCConfigurationList; 399 | buildConfigurations = ( 400 | 0430C1311F524ACE00860C50 /* Debug */, 401 | 0430C1321F524ACE00860C50 /* Release */, 402 | ); 403 | defaultConfigurationIsVisible = 0; 404 | defaultConfigurationName = Release; 405 | }; 406 | 0430C1331F524ACE00860C50 /* Build configuration list for PBXNativeTarget "DemoApplication" */ = { 407 | isa = XCConfigurationList; 408 | buildConfigurations = ( 409 | 0430C1341F524ACE00860C50 /* Debug */, 410 | 0430C1351F524ACE00860C50 /* Release */, 411 | ); 412 | defaultConfigurationIsVisible = 0; 413 | defaultConfigurationName = Release; 414 | }; 415 | /* End XCConfigurationList section */ 416 | }; 417 | rootObject = 0430C1191F524ACA00860C50 /* Project object */; 418 | } 419 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DemoApplication 4 | // 5 | // Created by Tomosuke Okada on 2017/08/27. 6 | // Copyright © 2017年 TomosukeOkada. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.3 19 | CFBundleVersion 20 | 1.3 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/ViewController/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DemoApplication 4 | // 5 | // Created by Tomosuke Okada on 2017/08/27. 6 | // Copyright © 2017年 TomosukeOkada. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import OTResizableView 12 | 13 | class ViewController: UIViewController,OTResizableViewDelegate { 14 | 15 | var resizableView = OTResizableView(contentView: UIView()) 16 | 17 | @IBOutlet weak var mainView: UIView! 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | let yourView = UIView(frame: CGRect(x: 70, y: 70, width: 200, height: 300)) 23 | yourView.backgroundColor = UIColor.blue 24 | 25 | resizableView = OTResizableView(contentView: yourView) 26 | resizableView.delegate = self; 27 | 28 | mainView.addSubview(resizableView) 29 | } 30 | 31 | 32 | override func didReceiveMemoryWarning() { 33 | super.didReceiveMemoryWarning() 34 | 35 | } 36 | 37 | @IBAction func tappedChangeAspectButton(_ sender: UIButton) { 38 | sender.isSelected = !sender.isSelected 39 | if sender.isSelected { 40 | resizableView.keepAspectEnabled = true 41 | } else { 42 | resizableView.keepAspectEnabled = false 43 | resizableView.minimumWidth = 100 44 | resizableView.minimumHeight = 100 45 | } 46 | } 47 | 48 | func tapBegin(_ resizableView: OTResizableView) { 49 | resizableView.resizeEnabled = resizableView.resizeEnabled ? false : true 50 | 51 | print("tapBegin:\(resizableView.frame)") 52 | } 53 | 54 | 55 | func tapChanged(_ resizableView: OTResizableView) { 56 | print("tapChanged:\(resizableView.frame))") 57 | } 58 | 59 | 60 | func tapMoved(_ resizableView: OTResizableView) { 61 | print("tapMoved:\(resizableView.frame))") 62 | } 63 | 64 | 65 | func tapEnd(_ resizableView: OTResizableView) { 66 | print("tapEnd:\(resizableView.frame)") 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /DemoApplication/DemoApplication/ViewController/ViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Tomosuke Okada 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OTResizableView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "OTResizableView" 4 | s.version = "1.3" 5 | s.summary = "OTResizableView is a UIView library that can be resized with fingers." 6 | s.homepage = "https://github.com/PKPK-Carnage/OTResizableView" 7 | s.license = { :type => "MIT", :file => "LICENSE" } 8 | s.author = { "Tomosuke Okada" => "pkpkcarnage@gmail.com" } 9 | s.social_media_url = "https://github.com/PKPK-Carnage" 10 | s.platform = :ios, "8.0" 11 | s.source = { :git => "https://github.com/PKPK-Carnage/OTResizableView.git", :tag => "#{s.version}" } 12 | s.source_files = "Classes", "Classes/*.{swift}" 13 | s.requires_arc = true 14 | 15 | end 16 | -------------------------------------------------------------------------------- /OTResizableView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0430C1421F524B8000860C50 /* OTResizableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430C1411F524B8000860C50 /* OTResizableView.swift */; }; 11 | 0430C14B1F525C4A00860C50 /* OTGripPointView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430C14A1F525C4A00860C50 /* OTGripPointView.swift */; }; 12 | 0430C14E1F52954D00860C50 /* OTResizableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0430C14D1F52954D00860C50 /* OTResizableView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXFileReference section */ 16 | 0430C1041F52499C00860C50 /* OTResizableView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OTResizableView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 17 | 0430C1081F52499C00860C50 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 18 | 0430C1411F524B8000860C50 /* OTResizableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTResizableView.swift; sourceTree = ""; }; 19 | 0430C14A1F525C4A00860C50 /* OTGripPointView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTGripPointView.swift; sourceTree = ""; }; 20 | 0430C14D1F52954D00860C50 /* OTResizableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTResizableView.h; sourceTree = ""; }; 21 | /* End PBXFileReference section */ 22 | 23 | /* Begin PBXFrameworksBuildPhase section */ 24 | 0430C1001F52499C00860C50 /* Frameworks */ = { 25 | isa = PBXFrameworksBuildPhase; 26 | buildActionMask = 2147483647; 27 | files = ( 28 | ); 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXFrameworksBuildPhase section */ 32 | 33 | /* Begin PBXGroup section */ 34 | 0430C0FA1F52499C00860C50 = { 35 | isa = PBXGroup; 36 | children = ( 37 | 0430C10F1F524A0500860C50 /* Classes */, 38 | 0430C1061F52499C00860C50 /* OTResizableView */, 39 | 0430C1051F52499C00860C50 /* Products */, 40 | ); 41 | sourceTree = ""; 42 | }; 43 | 0430C1051F52499C00860C50 /* Products */ = { 44 | isa = PBXGroup; 45 | children = ( 46 | 0430C1041F52499C00860C50 /* OTResizableView.framework */, 47 | ); 48 | name = Products; 49 | sourceTree = ""; 50 | }; 51 | 0430C1061F52499C00860C50 /* OTResizableView */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | 0430C1081F52499C00860C50 /* Info.plist */, 55 | 0430C14D1F52954D00860C50 /* OTResizableView.h */, 56 | ); 57 | path = OTResizableView; 58 | sourceTree = ""; 59 | }; 60 | 0430C10F1F524A0500860C50 /* Classes */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 0430C14A1F525C4A00860C50 /* OTGripPointView.swift */, 64 | 0430C1411F524B8000860C50 /* OTResizableView.swift */, 65 | ); 66 | path = Classes; 67 | sourceTree = ""; 68 | }; 69 | /* End PBXGroup section */ 70 | 71 | /* Begin PBXHeadersBuildPhase section */ 72 | 0430C1011F52499C00860C50 /* Headers */ = { 73 | isa = PBXHeadersBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | 0430C14E1F52954D00860C50 /* OTResizableView.h in Headers */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXHeadersBuildPhase section */ 81 | 82 | /* Begin PBXNativeTarget section */ 83 | 0430C1031F52499C00860C50 /* OTResizableView */ = { 84 | isa = PBXNativeTarget; 85 | buildConfigurationList = 0430C10C1F52499C00860C50 /* Build configuration list for PBXNativeTarget "OTResizableView" */; 86 | buildPhases = ( 87 | 0430C0FF1F52499C00860C50 /* Sources */, 88 | 0430C1001F52499C00860C50 /* Frameworks */, 89 | 0430C1011F52499C00860C50 /* Headers */, 90 | 0430C1021F52499C00860C50 /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = OTResizableView; 97 | productName = OTResizableView; 98 | productReference = 0430C1041F52499C00860C50 /* OTResizableView.framework */; 99 | productType = "com.apple.product-type.framework"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 0430C0FB1F52499C00860C50 /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastUpgradeCheck = 0900; 108 | ORGANIZATIONNAME = TomosukeOkada; 109 | TargetAttributes = { 110 | 0430C1031F52499C00860C50 = { 111 | CreatedOnToolsVersion = 8.3.3; 112 | DevelopmentTeam = NG4PAUE398; 113 | LastSwiftMigration = 0900; 114 | ProvisioningStyle = Manual; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = 0430C0FE1F52499C00860C50 /* Build configuration list for PBXProject "OTResizableView" */; 119 | compatibilityVersion = "Xcode 3.2"; 120 | developmentRegion = English; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | ); 125 | mainGroup = 0430C0FA1F52499C00860C50; 126 | productRefGroup = 0430C1051F52499C00860C50 /* Products */; 127 | projectDirPath = ""; 128 | projectRoot = ""; 129 | targets = ( 130 | 0430C1031F52499C00860C50 /* OTResizableView */, 131 | ); 132 | }; 133 | /* End PBXProject section */ 134 | 135 | /* Begin PBXResourcesBuildPhase section */ 136 | 0430C1021F52499C00860C50 /* Resources */ = { 137 | isa = PBXResourcesBuildPhase; 138 | buildActionMask = 2147483647; 139 | files = ( 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXResourcesBuildPhase section */ 144 | 145 | /* Begin PBXSourcesBuildPhase section */ 146 | 0430C0FF1F52499C00860C50 /* Sources */ = { 147 | isa = PBXSourcesBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | 0430C1421F524B8000860C50 /* OTResizableView.swift in Sources */, 151 | 0430C14B1F525C4A00860C50 /* OTGripPointView.swift in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin XCBuildConfiguration section */ 158 | 0430C10A1F52499C00860C50 /* Debug */ = { 159 | isa = XCBuildConfiguration; 160 | buildSettings = { 161 | ALWAYS_SEARCH_USER_PATHS = NO; 162 | CLANG_ANALYZER_NONNULL = YES; 163 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 164 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 165 | CLANG_CXX_LIBRARY = "libc++"; 166 | CLANG_ENABLE_MODULES = YES; 167 | CLANG_ENABLE_OBJC_ARC = YES; 168 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 169 | CLANG_WARN_BOOL_CONVERSION = YES; 170 | CLANG_WARN_COMMA = YES; 171 | CLANG_WARN_CONSTANT_CONVERSION = YES; 172 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 173 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 174 | CLANG_WARN_EMPTY_BODY = YES; 175 | CLANG_WARN_ENUM_CONVERSION = YES; 176 | CLANG_WARN_INFINITE_RECURSION = YES; 177 | CLANG_WARN_INT_CONVERSION = YES; 178 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 179 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 180 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 181 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 182 | CLANG_WARN_STRICT_PROTOTYPES = YES; 183 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 187 | COPY_PHASE_STRIP = NO; 188 | CURRENT_PROJECT_VERSION = 1; 189 | DEBUG_INFORMATION_FORMAT = dwarf; 190 | ENABLE_STRICT_OBJC_MSGSEND = YES; 191 | ENABLE_TESTABILITY = YES; 192 | GCC_C_LANGUAGE_STANDARD = gnu99; 193 | GCC_DYNAMIC_NO_PIC = NO; 194 | GCC_NO_COMMON_BLOCKS = YES; 195 | GCC_OPTIMIZATION_LEVEL = 0; 196 | GCC_PREPROCESSOR_DEFINITIONS = ( 197 | "DEBUG=1", 198 | "$(inherited)", 199 | ); 200 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 201 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 202 | GCC_WARN_UNDECLARED_SELECTOR = YES; 203 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 204 | GCC_WARN_UNUSED_FUNCTION = YES; 205 | GCC_WARN_UNUSED_VARIABLE = YES; 206 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 207 | MTL_ENABLE_DEBUG_INFO = YES; 208 | ONLY_ACTIVE_ARCH = YES; 209 | SDKROOT = iphoneos; 210 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 211 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 212 | TARGETED_DEVICE_FAMILY = "1,2"; 213 | VERSIONING_SYSTEM = "apple-generic"; 214 | VERSION_INFO_PREFIX = ""; 215 | }; 216 | name = Debug; 217 | }; 218 | 0430C10B1F52499C00860C50 /* Release */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_ANALYZER_NONNULL = YES; 223 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 224 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 225 | CLANG_CXX_LIBRARY = "libc++"; 226 | CLANG_ENABLE_MODULES = YES; 227 | CLANG_ENABLE_OBJC_ARC = YES; 228 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_COMMA = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 233 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 234 | CLANG_WARN_EMPTY_BODY = YES; 235 | CLANG_WARN_ENUM_CONVERSION = YES; 236 | CLANG_WARN_INFINITE_RECURSION = YES; 237 | CLANG_WARN_INT_CONVERSION = YES; 238 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 240 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 241 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 242 | CLANG_WARN_STRICT_PROTOTYPES = YES; 243 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | CURRENT_PROJECT_VERSION = 1; 249 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 250 | ENABLE_NS_ASSERTIONS = NO; 251 | ENABLE_STRICT_OBJC_MSGSEND = YES; 252 | GCC_C_LANGUAGE_STANDARD = gnu99; 253 | GCC_NO_COMMON_BLOCKS = YES; 254 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 255 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 256 | GCC_WARN_UNDECLARED_SELECTOR = YES; 257 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 258 | GCC_WARN_UNUSED_FUNCTION = YES; 259 | GCC_WARN_UNUSED_VARIABLE = YES; 260 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 261 | MTL_ENABLE_DEBUG_INFO = NO; 262 | SDKROOT = iphoneos; 263 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 264 | TARGETED_DEVICE_FAMILY = "1,2"; 265 | VALIDATE_PRODUCT = YES; 266 | VERSIONING_SYSTEM = "apple-generic"; 267 | VERSION_INFO_PREFIX = ""; 268 | }; 269 | name = Release; 270 | }; 271 | 0430C10D1F52499C00860C50 /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | CLANG_ENABLE_MODULES = YES; 275 | CODE_SIGN_IDENTITY = ""; 276 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 277 | DEFINES_MODULE = YES; 278 | DEVELOPMENT_TEAM = NG4PAUE398; 279 | DYLIB_COMPATIBILITY_VERSION = 1; 280 | DYLIB_CURRENT_VERSION = 1; 281 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 282 | INFOPLIST_FILE = OTResizableView/Info.plist; 283 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 284 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = TomosukeOkada.OTResizableView; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | PROVISIONING_PROFILE_SPECIFIER = ""; 289 | SKIP_INSTALL = YES; 290 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 291 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 292 | SWIFT_VERSION = 4.0; 293 | }; 294 | name = Debug; 295 | }; 296 | 0430C10E1F52499C00860C50 /* Release */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | CLANG_ENABLE_MODULES = YES; 300 | CODE_SIGN_IDENTITY = ""; 301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 302 | DEFINES_MODULE = YES; 303 | DEVELOPMENT_TEAM = NG4PAUE398; 304 | DYLIB_COMPATIBILITY_VERSION = 1; 305 | DYLIB_CURRENT_VERSION = 1; 306 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 307 | INFOPLIST_FILE = OTResizableView/Info.plist; 308 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 309 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 310 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 311 | PRODUCT_BUNDLE_IDENTIFIER = TomosukeOkada.OTResizableView; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | PROVISIONING_PROFILE_SPECIFIER = ""; 314 | SKIP_INSTALL = YES; 315 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 316 | SWIFT_VERSION = 4.0; 317 | }; 318 | name = Release; 319 | }; 320 | /* End XCBuildConfiguration section */ 321 | 322 | /* Begin XCConfigurationList section */ 323 | 0430C0FE1F52499C00860C50 /* Build configuration list for PBXProject "OTResizableView" */ = { 324 | isa = XCConfigurationList; 325 | buildConfigurations = ( 326 | 0430C10A1F52499C00860C50 /* Debug */, 327 | 0430C10B1F52499C00860C50 /* Release */, 328 | ); 329 | defaultConfigurationIsVisible = 0; 330 | defaultConfigurationName = Release; 331 | }; 332 | 0430C10C1F52499C00860C50 /* Build configuration list for PBXNativeTarget "OTResizableView" */ = { 333 | isa = XCConfigurationList; 334 | buildConfigurations = ( 335 | 0430C10D1F52499C00860C50 /* Debug */, 336 | 0430C10E1F52499C00860C50 /* Release */, 337 | ); 338 | defaultConfigurationIsVisible = 0; 339 | defaultConfigurationName = Release; 340 | }; 341 | /* End XCConfigurationList section */ 342 | }; 343 | rootObject = 0430C0FB1F52499C00860C50 /* Project object */; 344 | } 345 | -------------------------------------------------------------------------------- /OTResizableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OTResizableView.xcodeproj/xcshareddata/xcschemes/OTResizableView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 72 | 73 | 74 | 75 | 77 | 78 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /OTResizableView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.3 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /OTResizableView/OTResizableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // OTResizableView.h 3 | // OTResizableView 4 | // 5 | // Created by Tomosuke Okada on 2017/08/27. 6 | // Copyright © 2017年 TomosukeOkada. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for OTResizableView. 12 | FOUNDATION_EXPORT double OTResizableViewVersionNumber; 13 | 14 | //! Project version string for OTResizableView. 15 | FOUNDATION_EXPORT const unsigned char OTResizableViewVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OTResizableView 2 | 3 | ## Description 4 | OTResizableView is a UIView library that can be resized with fingers. 5 | 6 | ## Features 7 | ・Resize 8 | 9 | ・Keep aspect resize 10 | 11 | ・Move 12 | 13 | ・Change color 14 | 15 | ## Demo 16 | ![OTResizableVIewDemo.gif](https://qiita-image-store.s3.amazonaws.com/0/152335/4247576c-8532-e632-c335-6445634904b7.gif "OTResizableVIewDemo.gif") 17 | 18 | ## Usage 19 | 20 | ```swift 21 | 22 | import OTResizableView 23 | 24 | let resizableView = OTResizableView(contentView: yourView) 25 | resizableView.delegate = self; 26 | 27 | // If you want to change resizableView colors, you can customize here. 28 | 29 | view.addSubview(resizableView) 30 | 31 | 32 | ``` 33 | 34 | ## Install 35 | 36 | ### CocoaPods 37 | Add this to your Podfile. 38 | 39 | ```PodFile 40 | pod 'OTResizableView' 41 | ``` 42 | 43 | ### Carthage 44 | Add this to your Cartfile. 45 | 46 | ```Cartfile 47 | github "PKPK-Carnage/OTResizableView" 48 | ``` 49 | 50 | ## Help 51 | 52 | If you want to support this framework, you can do these things. 53 | 54 | * Please let us know if you have any requests for me. 55 | 56 | I will do my best to live up to your expectations. 57 | 58 | * You can make contribute code, issues and pull requests. 59 | 60 | I promise to confirm them. 61 | 62 | ## Licence 63 | 64 | [MIT](https://github.com/PKPK-Carnage/OTResizableView/blob/master/LICENSE) 65 | 66 | ## Author 67 | 68 | [PKPK-Carnage🦎](https://github.com/PKPK-Carnage) 69 | --------------------------------------------------------------------------------