All Projects → snoozelag → GoneVisible

snoozelag / GoneVisible

Licence: MIT license
GoneVisible is a UIView extension that uses AutoLayout to add "gone" state like Android.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to GoneVisible

Easyswiftlayout
Lightweight Swift framework for Apple's Auto-Layout
Stars: ✭ 345 (+1177.78%)
Mutual labels:  uiview, autolayout
Leego
Declarative, configurable & highly reusable UI development as making Lego bricks.
Stars: ✭ 967 (+3481.48%)
Mutual labels:  uiview, autolayout
Quicklayout
Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.
Stars: ✭ 213 (+688.89%)
Mutual labels:  uiview, autolayout
Anwexpandscrollview
Expand - Collapse Scroll View - Animate With Pinch Gesture
Stars: ✭ 125 (+362.96%)
Mutual labels:  uiview
Closures
Swifty closures for UIKit and Foundation
Stars: ✭ 1,720 (+6270.37%)
Mutual labels:  uiview
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (+162.96%)
Mutual labels:  uiview
JustUiKit
iOS UI Kit With Android-Style Tools. JustUiKit contains JustLinearLayout, JustFrameLayout and so on. It is designed to make Android developers build iOS UI easily. Also for iOS developers, it provides a new way to build UI.
Stars: ✭ 35 (+29.63%)
Mutual labels:  uiview
Dry View
Complete, standalone view rendering system that gives you everything you need to write well-factored view code.
Stars: ✭ 124 (+359.26%)
Mutual labels:  uiview
StoryboardConstraint
A simple way to use programmatically Autolayout Constraint created in Storyboard.
Stars: ✭ 25 (-7.41%)
Mutual labels:  autolayout
Animation Extensions
A set of most commonly used animations like rotation, shake, flip or motion effects. All in one UIView extension.
Stars: ✭ 198 (+633.33%)
Mutual labels:  uiview
Easytipview
Objective-C alternative for EasyTipView implemented in swift
Stars: ✭ 192 (+611.11%)
Mutual labels:  uiview
Instagramactivityindicator
Activity Indicator similar to Instagram's.
Stars: ✭ 138 (+411.11%)
Mutual labels:  uiview
YRipple
iOS Ripple Effect, Xcode10 and Swift5 available
Stars: ✭ 18 (-33.33%)
Mutual labels:  uiview
Flareview
Create Animatic flares around your uiview's. Visit http://stanlyhardy.github.io/FlareView for more info
Stars: ✭ 136 (+403.7%)
Mutual labels:  uiview
SBLayout
【一行代码搞定无论多复杂的约束】AutoLayout for iOS/macOS by swift
Stars: ✭ 46 (+70.37%)
Mutual labels:  autolayout
Lsanimator
⛓ Easy to Read and Write Multi-chain Animations Lib in Objective-C and Swift.
Stars: ✭ 1,576 (+5737.04%)
Mutual labels:  uiview
SDCAutoLayout
A UIView category that simplifies dealing with Auto Layout
Stars: ✭ 23 (-14.81%)
Mutual labels:  autolayout
Render
UIKit a-là SwiftUI.framework [min deployment target iOS10]
Stars: ✭ 2,150 (+7862.96%)
Mutual labels:  uiview
Inappviewdebugger
A UIView debugger (like Reveal or Xcode) that can be embedded in an app for on-device view debugging
Stars: ✭ 1,805 (+6585.19%)
Mutual labels:  uiview
SideMenuSwiftDemo
SideMenu in Swift with autolayout
Stars: ✭ 79 (+192.59%)
Mutual labels:  autolayout

GoneVisible

Platform Language License Twitter

GoneVisible is a UIView extension that uses AutoLayout to add "gone" state like Android.

You can easily change the size constraint constant of UIView to 0 without adding IBOutlet property of size constraint. GoneVisible supports iOS and is written in Swift.

Additional notes: This library will be useful for projects targeting iOS 8. If your project is targeting iOS 9 or higher, I recommend you consider implementing with UIStackView before using this library.  
 

Requirements

  • Swift 4.0
  • iOS 8.0+
  • Xcode 9

Installation

Manual

Simply drag UIView+GoneVisible.swift into your project.

Cocoapods

  • Add into your Podfile.
pod "GoneVisible"

Then $ pod install

  • Add import GoneVisible to the top of your files where you wish to use it.

Usage

・Gone.

view.gone()

・Visible.

view.visible()

・When setting to Gone, set the space constraint constant together to 0.

view.gone(spaces: [.trailing])

・With "gone" you can specify whether it is vertical or horizontal. It is useful when animating.

view.gone(axis: .vertical)

Example Code

Here is the code for this example project. You do not need to import constraints by IBoutlet to control size.

import UIKit
import GoneVisible

class ViewController: UIViewController {

    @IBOutlet weak private var blackView: UIView!
    @IBOutlet weak private var redView: UIView!
    @IBOutlet weak private var blueView: UIView!
    @IBOutlet weak private var yellowButton: UIButton!
    @IBOutlet weak private var errorMessageLabel: UILabel!
    @IBOutlet weak private var toggleSwitch: UISwitch!

    override func viewDidLoad() {
    super.viewDidLoad()

        // When you want to display in "gone" state from the beginning.
//        toggleSwitch.isOn = false
//        goneViews()
    }

    @IBAction func toggleSwitchValueChanged(_ sender: UISwitch) {
        if toggleSwitch.isOn {
            visibleViews()
            UIView.animate(withDuration: 0.3) { view.layoutIfNeeded() }
        } else {
            goneViews()
            UIView.animate(withDuration: 0.3) { view.layoutIfNeeded() }
        }
    }

    private func goneViews() {
        blackView.gone()
        redView.gone(axis: .vertical, spaces: [.bottom])
        blueView.gone(axis: .horizontal, spaces: [.trailing])
        yellowButton.gone(axis: .horizontal, spaces: [.trailing])
        errorMessageLabel.gone(axis: .vertical)
    }

    private func visibleViews() {
        blackView.visible()
        redView.visible()
        blueView.visible()
        yellowButton.visible()
        errorMessageLabel.visible()
    }

}
See also:

Author

Teruto Yamasaki, [email protected]

License

The MIT License (MIT)
See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].