Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

forkingdog/UIView-FDCollapsibleConstraints

Repository files navigation

forkingdog

Overview

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

Demo 1

This demo collapses theforkingdog 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 aIBOutletCollection 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 likeUILabel,UIImageView have theirIntrinsic content size when they have content in it. For these views, we provide aAuto 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 enableauto collapse:

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

Here's what you may find inAttribute Inspector

auto collapse

It's behavior is same as settingfd_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

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp