• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An easy way to create and update AutoLayout Constraints (Mainly to update Width and Height of UIView)

UIView-UpdateAutoLayoutConstraints

An easy way to create and update AutoLayout Constraints (Mainly to update Width and Height of UIView)

alt text

1 - import Category

#import "UIView+UpdateAutoLayoutConstraints.h"

2 - create your UIViews

UIView *myView1 = [[UIView alloc]init];
one.backgroundColor = [UIColor redColor];
one.translatesAutoresizingMaskIntoConstraints = NO;  //<<-- Don't forget this line to enable AutoLayout
[self.view addSubview:one];

UIView *myView2 = [[UIView alloc]init];
two.backgroundColor = [UIColor blueColor];
two.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:two];

3 - create initial constraints

NSDictionary *metrics = @{@"height":@50.0};
NSDictionary *views = NSDictionaryOfVariableBindings(myView1,myView2);

[self.view addConstraints:[NSLayoutConstraint
                           constraintsWithVisualFormat:@"|-[one]-|"
                           options: 0
                           metrics:metrics
                           views:views]];

[self.view addConstraints:[NSLayoutConstraint
                                 constraintsWithVisualFormat:@"V:|-[myView1(50)][myView2]]"
                                 options:NSLayoutFormatAlignAllLeft | NSLayoutFormatAlignAllRight
                                 metrics:metrics
                                 views:views]];
                                     

4 - Whenever you want, Update this constraint

//Hide View
[myView1 setConstraintConstant:0 forAttribute:NSLayoutAttributeHeight];

//if constraint doesn't exist, it will be created
[myView1 setConstraintConstant:20 forAttribute:NSLayoutAttributeWidth];

//you can use tools to hide/show a uiview
[myView1 hideByHeight:YES];

//then
[myView1 hideByHeight:NO];

More Repositories

1

CollectionViewCustom

Custom CollectionViewLayout with a custom paging size by overriding scrollViewWillEndDragging
Swift
103
star
2

VisibleFormViewController

An extended UIviewController allowing to not hide the content behind the keyboard opened.
Objective-C
40
star
3

UIButton-setBackgroundColor-forState-

an Objective-c Category to add the method setBackgroundColor:forState: to the UIButton
Objective-C
18
star
4

NSString-Matcher

An Objective-c category providing a easy way to match NSString with a Regex
Objective-C
8
star
5

NSObject-FromClassName

In swift, get quickly an NSObject from its classname
Swift
6
star
6

express-sync

How to use an express server with browser-sync (without gulp)
JavaScript
5
star
7

CustomTabBarController

To understand how build a view container of navigationcontroller, the best way is to recreate the UITabBarController.
Objective-C
3
star
8

jquery-vertical-slider

Jquery Mobile don't allow to display slider vertically. I need it to working on a project, then I continued the work of @elmundio87
JavaScript
2
star
9

RFDuino-adafruit-lSM9DS0

I'm Working on a RFDUINO and a Adafruit LSM9DS0 (Accelerometer + Gyro + Magnetometer). RFDUINO send Accelerometer's data to an IOS app by Bluetooth
Objective-C
2
star
10

damienromito

Portfolio
JavaScript
1
star
11

WDMessage

Display notifications in the app with several options and simple customisations
Objective-C
1
star
12

UIView-AutoYPositioning

A simple way to stack dynamic UIView
Objective-C
1
star
13

SwiftInObjectiveC

A very simple demo of a working practice to use Swift into an Objective-c project
Objective-C
1
star
14

DRLabel

A Subclass of UILabel allowing to have padding in my Label
Objective-C
1
star