Auto-Layout in iOS 7
Upcoming SlideShare
Loading in...5
×
 

Auto-Layout in iOS 7

on

  • 605 views

On iPhone and iPad if one's designs were reasonably complex, you would have to be involved in writing a lot of ...

On iPhone and iPad if one's designs were reasonably complex, you would have to be involved in writing a lot of
code to support such adaptive layouts. With Auto Layout it makes it easy to support different screen sizes in your apps.

Statistics

Views

Total Views
605
Views on SlideShare
603
Embed Views
2

Actions

Likes
0
Downloads
5
Comments
0

1 Embed 2

http://www.slideee.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Auto-Layout in iOS 7 Auto-Layout in iOS 7 Presentation Transcript

    • Auto-Layout in iOS 7 By Pushpendra Singh
    • Layout Layout Consist of four things: • Center • Bounds • Auto-resizing mask • Transform
    • Auto Layout Using Auto Layout, you can create a dynamic and versatile interface that responds appropriately to changes in screen size, device orientation, and localization.
    • Basic Concept Expression of the form y = m*x + b, where: y and x are attributes of views. m and b are floating point values. An attribute is one of left, right, top, bottom, leading, trailing, width, height, centerX, centerY, and baseline.
    • constraints Layout NSLayoutConstraint Content NSContentSizeLayoutConstraint AutosizingNSAutoresizingMaskLayoutConstraint
    • Constraints Attribute view1.attribute1 RELATION multiplier * view2.attribute2 + constant NSLayoutAttributeLeft NSLayoutAttributeRight NSLayoutAttributeTop NSLayoutAttributeBottom NSLayoutAttributeLeading NSLayoutAttributeTrailing NSLayoutAttributeWidth NSLayoutAttributeHeight NSLayoutAttributeCenterX NSLayoutAttributeCenterY NSLayoutAttributeBaseline NSLayoutRelationEqual NSLayoutRelationGreaterThanOrEqual NSLayoutRelationLessThanOrEqual NSLayoutAttributeNotAnAttribute
    • Constraints Code view1.attribute1 RELATION multiplier * view2.attribute2 + constant constraint = [NSLayoutConstraint constraintWithItem: view attribute: NSLayoutAttributeWidth relatedBy: NSLayoutRelationEqual toItem: nil attribute: NSLayoutAttributeNotAnAttribute multiplier: 1.0 constant:100.0]; [view addConstraint: constraint]; constraint = [NSLayoutConstraint constraintWithItem: view attribute: NSLayoutAttributeWidth relatedBy: NSLayoutRelationEqual toItem: nil attribute: NSLayoutAttributeNotAnAttribute multiplier: 1.0 Constant: 80.0]; [view addConstraint: constraint];
    • Check For Ambiguous Layout view.hasAmbiguousLayout view.exerciseAmbiguityInLayout for (UIView *view in self.subviews) { if ([view hasAmbiguousLayout]){ NSLog(@"<%@:0x%0x>", view.description, (int)self); } }
    • Intrinsic ContentSize Suggested size for the view. - (CGSize) intrinsicContentSize { return mySize; } [self invalidateIntrinsicContentSize]; UIImage *img = UIImage imageNamed:@"Icon.png"]; UIImageView *iv = [[UIImageView alloc] initWithImage:img]; NSLog(@"%@", NSStringFromCGSize(iv.intrinsicContentSize));
    • Visual Format Language [NSLayoutConstraint ! constraintsWithVisualFormat:@"H:|-[buttonA]-|" ! options:0 ! metrics:nil ! views:@{@"buttonA":buttonA}];
    • UIView Opting in to Constraint-Based Layout + requiresConstraintBasedLayout – translatesAutoresizingMaskIntoConstraints – setTranslatesAutoresizingMaskIntoConstraints: Managing Constraints – – – – – constraints addConstraint: addConstraints: removeConstraint: removeConstraints: Measuring in Constraint-Based Layout – – – – – – – systemLayoutSizeFittingSize intrinsicContentSize invalidateIntrinsicContentSize contentCompressionResistancePriorityForAxis: setContentCompressionResistancePriority:forAxis: contentHuggingPriorityForAxis: setContentHuggingPriority:forAxis:
    • UIView Aligning Views with Constraint-Based Layout – – – – alignmentRectForFrame: frameForAlignmentRect: alignmentRectInsets viewForBaselineLayout Triggering Constraint-Based Layout – – – – needsUpdateConstraints setNeedsUpdateConstraints updateConstraints updateConstraintsIfNeeded Debugging Constraint-Based Layout – constraintsAffectingLayoutForAxis: – hasAmbiguousLayout – exerciseAmbiguityInLayout
    • Queries