introducedAndroid Studio
Introducing AutoLayout into the
dependencies {
Compile project (': AutoLayout ')
}
You can also directly
dependencies {
compile ' com.zhy:autolayout:1.4.3 '
}
Eclipse
It is recommended to use as for easy version updates. Really not, only copy and paste the source code. usage The first step:
In the androidmanifest of your project, indicate the size of your design manuscript.
After the interface uses automatic layout, the value of the frame in the Viewdidload method in the code is not real-time and is still a frame relative to the 600 * 600 interface. needs to be obtained in viewwillappear or Viewdidappear methods. The UIView frame is correct, because the view is all initialized at this time.The question of a cagradientlayer frame is recorded, and its frame is relative to the location of the parent view (that is, the view that needs to be insertsublayer), so the posi
];[cell.logoImageViewsetImage:[UIImageimageNamed:[imageArrayobjectAtIndex:indexPath.row]]];[cell.detailLabelsetText:[descriptionArrayobjectAtIndex:indexPath.row]];returncell;}
Run again, you can see the desired effect in the IOS6,IT ' S Perfect!!!In short, the study of the layout of a few days, found iOS good pit, a variety of traps, fortunately consulted a variety of domestic and foreign information, and ultimately achieve the effect.Project Source: Https://github.com/zhangxh6931/Autola
attribute:nslayoutattributewidth Multiplier:0.5constant0]; the [Redview.superview addconstraint:redwidth]; the the //modifying constraints for animating effects the -UIButton *btn =[UIButton Buttonwithtype:uibuttontypecustom]; the the[Btn Setframe:cgrectmake (0, -, -, -)]; the[BTN Settitle:@"Moving"Forstate:uicontrolstatenormal];94 [btn Setbackgroundcolor:[uicolor orangecolor]; the [Self.view addsubview:btn]; the [btn addtarget:self Action: @selector (Btnclick) forcontrolevents:u
string used in the format string which stands for some nsnum ber value, and we could use NSNumber value directly or constant even computed variable as the value referenced by the Stri Ng Key.E.views:this is a dictionary so used to declare all the components used in format string like [Component], is a type of [String:anyobject], we use the key string to stands for the component related to the dictionary in the format string.Sorry guys i ' m using a Chinese blog website, so I had no idea if ther
outlet and clicking the event action:Here I put Thing1 and THING0 close, I want to let Thing1 automatic layout relies on THING0, click Thing1 Ctrl-Drag mouse to THING0, release after Xcode will be the frame let you choose constraints, you can choose leading, Center horizontally, trailling, respectively, is the forefront, the center level, after the face alignment, add the desired constraints after the Click Thing1 can see the constraint lineFigure 7: Setting constraints in a drag-and-drop manne
Add ScrollView and its child views
Parent view. Addsubview (ScrollView)
Scrollview.addsubview (Container)--container is a placeholder view
Container.addsubviews (true · Want to show the views)
Pull (or masturbate) constraints
ScrollView. Four sides stick to the parent view. Four edges
Container. Four-sided adhesion ScrollView.
Container.width = Scrollview.width (if you want to implement horizontal scrolling, it is Container.height = scrollv
displayTest Feedback TwoTest one inside, verify the concept of the various screens applicable to the combination, next, is a size Class to solve the magical use of horizontal screenPS: Used in, horizontal screen adaptation, re-typesetting the vertical screen when the UI layoutIn addition to changing the constraints under different combinations, you can change whether the controls are displayed under different combinationsTest Feedback ThreeAutoLayout here does not give specific how to set up, b
number of different types of simulators have just been switched, which is equivalent to switching between different size classes, but the green view is normal, and the size class exists to distinguish between different size Class (for example: iphone4s horizontal screen wcompact/hcompact,iphone4s vertical screen wcompact/hregular,ipad screen is wregular/hregular), and then to do a different UI layout, what solution? The current size class is wany/hany, which means that when the size class is Wa
1. Drag 1 Uiscrollview into the Viewcontroller and add a constraint to itConstrain the upper and lower left edges to align with the superview2. In ScrollView, drag in 1 uiview to make it orange for the sake of distinction.3. Adding a constraint to a viewConstrain the upper and lower left edges to align with the superviewAfter adding these constraints, we found that there was an error, ignoring4. To add a width constraint to the view, in this case, the effect is that scrollview can be scrolled ve
]; Self.tableView.tableHeaderView= Self.headerview;? 1. When modifying the TableView Tableheaderview interface, the interface does not refresh in time and can be called manually layoutifneeded the view height is the ideal height2.tableViewHeader height changes, the interface can not be refreshed in time need to re-set the Headerview to TableView Tableheaderview, the interface can be displayed correctly3. Of course, when using auto layout, the constraints must be sufficient to calculate the corre
For a view, add it to a superview and set the constraint, for example, to set the height constraint to 100If you manipulate the view again, add it to another superview, and then set the constraint again, the constraint that was previously attached to the view will not be emptied because of its superview change, and there is a constraint violation.How to resolve:When you add a constraint again, you should first empty the previous constraint, and for masonry, use Remakeconstraint instead of makeco
layout is a distance from the parent view 100, and the other rightbottomview below the Rightview is the equivalent of clinging*/Nsarray*rightbottomview_v = [Nslayoutconstraint constraintswithvisualformat:@"V:|-100-[rightview (>=50)][rightbottomview (>=100)]"Options0Metrics:nil Views:viewdic]; [Self.view Addconstraints:leftview_h]; [Self.view Addconstraints:leftview_v]; [Self.view Addconstraints:rightview_h]; [Self.view Addconstraints:rightview_v]; [Self.view Addconstraint
Common errors with AutoLayout1:the view hierarchy isn't prepared for the constraint: When added to a view, the constraint ' s items must is descendants of that view (or the view itself). This would crash if the constraint needs to being resolved before the view hierarchy is assembled. Break on-[uiview _viewhierarchyunpreparedforconstraint:] to Debug.This error is to be added to the current view immediately after creating the Searchbar, otherwise there will be a warning when the constraint is add
18. Set the width height and the lower boundary constraint19. Because the button needs to be displayed on the third chart, we set it to be centered horizontally on the third chart. Select both the button and the third picture.20, choose Align Item, pop-up menu select "Horizontal Centers"21. At this point, all settings are complete. To make it easier to see the effect, set three pictures in different colors.22, run a bit, see the effect bar.The above demo hope can help you. If you have any questi
This is just one line of code. For details, please see:
In order to get the right frame/bounds of your Uiimageview after resizing, you need first ask Auto-layout to Updat E The layout using [Yourimageview layoutifneeded]. That'll solve your constraints and update your yourimage . Bounds. [Myimageview layoutifneeded];NSLog(@"W:%f, H:%f", MyImageView.bounds.size.width, myImageView.bounds.size.height);
Just one line of code!Or get the frame in this method:-(void) vi
added to completion. Content that needs scrolling can be added in yellow view.Click Run to see the effectYou can see that the ScrollView can slide as expectedFinally, all the constraints seeUiscrollview Add constraint points:The constraint relationship between 1.scrollView and ScrollView Superview is used to determine the ScrollView frameThe constraint relationship of "Contentview" (blue view in this example) in 2.scrollView is used to determine the contentinsets of ScrollViewThe width and heig
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.