Objective:Recalling the 2013 years of iOS development, it was not in the way of handwritten layout code, but in the Xib file to write, if the use of pure code is based on the window size (320,480) to calculate a relative position to layout, At that time, the size of Windows was fixed, and with the release of Iphone5, the size of Windows (320,568) changed, and the Autoresizingmask approach was adapted to the later iphone 6 windows The width of size also changed, and began to abandon Autoresizingm
First, before we formally use masonry, let's take a look at how we use AutoLayout in Xib. As we can see, as long as the corresponding limitations are set, controlling the relationship between the parent and child views should be OK to drag out the requirements you need. Here is not a detailed explanation of the specific drag-and-drop method .....Then we press the properties to see how easy it is to use masonryThis is the property that
We know that the interface layout can be implemented with storyboard or xib combination of AutoLayout, if using a pure code layout, compared to the popular masonry, sdautolayout, the following simple demo, using a pure code layout, to achieve the indefinite high tableview.Implementation mode: Masonry + FdtemplatelayoutcellFirst:Among them: 1 and 2 are Uilabel, the content is not fixed, so the height is not
This article forwards to http://www.tuicool.com/articles/MRbaEnB/Original Http://www.infoq.com/cn/news/2014/11/masonry-introduction-practiseTutorial
Introduction and use of Masonry (Quick Start AutoLayout): After IPhone6 was released, I knew it was imperative to use AutoLayout, and I remembered a third-party library masonry I had seen before on GitHub. After
brownColor];[self.view addSubview:view1];[view1 mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.view); make.top.equalTo(self.view).with.offset(30); make.left.equalTo(self.view).with.offset(30); make.bottom.equalTo(self.view).with.offset(-30); make.right.equalTo(self.view).with.offset(-30);}];It is important to note that when the control is constrained with masonry, the control must be loaded into the parent v
Masonry is a lightweight layout framework that has its own description syntax with a more elegant chained syntax that encapsulates auto-layout, is concise, and is highly readable, and supports both IOS and Max OS x.If you use the system with the Nslayoutconstraint code volume will be very large, but also not good use.Below is the use of Source link a href= "Https://github.com/SnapKit/Masonry">
1 //2 //VIEWCONTROLLER.M3 //E01. Masonry basic Use4 //5 //Created by Apple on 15/8/8.6 //Copyright (c) 2015 Apple. All rights reserved.7 //8 9 #import "ViewController.h"Ten One //Define this constant if you want to use masonry without the ' mas_ ' prefix A //if you want to omit the Mas_ prefix when using masonry, define the following macro - #defineMas_shorthand
1. Masonry overview
Currently the most popular AutoLayout third-party framework
Write AutoLayout in an elegant code wayOmit Apple's official disgusting AutoLayout code.Greatly improved the development efficiency
Frame address:https://github.com/SnapKit/Masonry
2. Common methods
This method will only add new constraints.
[Blueview mas_makeconstraints:^ (Masconstrain
About the iOS layout automatically after the IPhone6 is Autolayout,autolayout is very good, but sometimes we need to page layout manually, the VFL is a choice, and the VFL is not complex, understanding is very easy, the actual development of the special cooked well, It would take a bit of work to get the first look. Masonry is a simplified version of the VFL, the use of more people, before the project used once, for manual writing page development is
ObjectiveWhen iOS it comes to automatic layout, there are a lot of workarounds. Some people use xib/storyboard automatic layout, and others use it frame to fit. For the former, I do not like, nor support. For the latter, it is troublesome, everywhere calculate height, width, etc., tens of millions of redundant code, the maintenance and development of the efficiency are very low.The author introduces the third-party library of pure Code automatic layout here:
With Masonry, you can easily implement waterfall streams. This article implements a simple graphic waterfall effect, as shown below:
The two elements of the graphic waterfall stream display are the image path and text content. The corresponding Model is:
namespace MvcApplication1.Models{ public class News { public string ImgUrl { get; set; } public string Content { get; set; } }}
In HomeController, the set instance of the M
Reprinted from: http://www.henishuo.com/masonry-tableviewcell-layout/prefaceWhen iOS it comes to automatic layout, there are a lot of workarounds. Some people use xib/storyboard automatic layout, and others use it frame to fit. For the former, I do not like, nor support. For the latter, it is troublesome, everywhere calculate height, width, etc., tens of millions of redundant code, the maintenance and development of the efficiency are very low.The aut
1. Use Cocoapods to load the three-party (pod ' masonry ')
2. Bridging
First establish (. h)
3. (. h) introducing masonry into the document, referring to the official naming Header-briding-header
4. Search bridging in Build Setting find objective-c bridging Header and write (. h) File path to
5. Then you can use it normally.
For example:
Using masonry
Le
During OC development I used a third-party AutoLayout library called Masonry, and after turning to Swift found that although Swift can be mixed OC, but always feel a bit of trouble, found on GitHub, this is called Snapkit third-party library, found to use more convenient, Share with you1. Download Snapkit on GitHub, choose iOS target Compilation (command+b), find Snapkit.framework2. Right button "Show in Finder"3. Drag this file into our project4, two
To add a constraint to a view, its dependent constraints must first exist, cannot rely on the code after the constraints, or cause unpredictable results, the following code can achieve the desired effect- (void) makeconstraints {__weaktypeof(self) weakself =Self ; [Self.photomorebutton mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.right.equalTo (Weakself.photobutton). With.offset (-6); Make.centerY.equalTo (Weakself.photobutton); Make.width.and.height.equalTo (@ -); }]; [
要求:When the keyboard is blocking the input box, the input box automatically bounces up to the top of the keyboard.实现:Here's another way to use the masonry mas_updateConstraints . This method is used to update control constraints.The specific implementation of the demo can be downloaded to see, this is only posted when the keyboard Popup processing code:- (void) Keyboardwillchangeframenotification: (Nsnotification *) Notification {Get keyboard Basics (
ObjectiveWhen iOS it comes to automatic layout, there are a lot of workarounds. Some people use xib/storyboard automatic layout, and others use it frame to fit. For the former, I do not like, nor support. For the latter, it is troublesome, everywhere calculate height, width, etc., tens of millions of redundant code, the maintenance and development of the efficiency are very low.The author introduces the third-party library of pure Code automatic layout here:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.