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 - forkingdog/UIView-FDCollapsibleConstraints: Builds to collapse a view and its relevant layout constraints, simulating a "Flow Layout" mode

BranchesTags
Open more actions menu

Latest commit

 

History

30 Commits
30 Commits

Folders and files

NameName
Last commit message
Last commit date
Classes
Classes
 
 
Demo
Demo
 
 
Sceenshots
Sceenshots
 
 
UIView+FDCollapsibleConstraints.xcworkspace
UIView+FDCollapsibleConstraints.xcworkspace
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
UIView+FDCollapsibleConstraints.podspec
UIView+FDCollapsibleConstraints.podspec
 
 

Repository files navigation

UIView-FDCollapsibleConstraints

forkingdog

Overview

UIView+FDCollapsibleConstraints builds to collapse a view and its relevant layout constraints, simulating a "Flow Layout" mode.

Demo 1

This demo collapses the forkingdog image view and its bottom margin constraint.

view demo

Demo 2

This demo collapses diffent components in cell, according to its data entity, each margin handles right as well.

cell demo

Basic usage

1. Select constraints to collapse

First, tell which constraints will be collapsed when the view collapses. We provide a IBOutletCollection to make it easier in Interface Builder:

@property (nonatomic, copy) IBOutletCollection(NSLayoutConstraint) NSArray *fd_collapsibleConstraints;

You can assgin it by codes, but it's better to "connect lines" in Interface Builder:

connecting lines

2. Collapse a view

Selected constraints will collapse when:

view.fd_collapsed = YES;

collapsed

And expand back when:

view.fd_collapsed = NO;

recovered

Auto collapse

Not every view needs to add a width or height constraint, views like UILabel, UIImageView have their Intrinsic content size when they have content in it. For these views, we provide a Auto collapse property, when its content is gone, selected constraints will collapse automatically.
You can enable auto collapse by:

label.fd_autoCollapse = YES;
imageView.fd_autoCollapse = YES;

And it will work as you expect:

label.text = nil/*or @""*/; (auto => label.fd_collapsed = YES)
label.text = @"forkingdog"; (auto => label.fd_collapsed = NO)
imageView.image = nil; (auto => imageView.fd_collapsed = YES)
imageView.image = [UIImage imageNamed:@"forkingdog"]; (auto => imageView.fd_collapsed = NO)

We've also offered a Interface Builder friendly way to enable auto collapse:

@property (nonatomic, assign, getter=fd_autoCollapse) IBInspectable BOOL autoCollapse;

Here's what you may find in Attribute Inspector

auto collapse

It's behavior is same as setting fd_autoCollapse property in code.

Installation

Cocoapods:

pod search UIView+FDCollapsibleConstraints

License

MIT

About

Builds to collapse a view and its relevant layout constraints, simulating a "Flow Layout" mode

Resources

Readme
MIT license
Activity
Custom properties

Stars

1.1k stars

Watchers

34 watching

Forks

160 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — 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.