1. 基礎屬性
##########
1. left, right, top, bottom//左邊, 右邊, 上邊, 下邊
2.width, height, maxWidth, maxHeight, minWidth, minHeight;//設置寬度, 高度, 最大寬度, 最大高度, 最小寬度, 最小高度
3,centerX, centerY;//中心X軸, 中心Y軸
4 offset(偏移量, 原點在左上角, 偏移遠離值為正, 偏移靠近值為負);
2.##########關系
1, equalTo
2.spaceTo
3,ratioTo
4.is
#######################方法
leftEqualToView(<UIView>) //左邊與目標左邊齊平
rightEqualToView(<UIView>) //右邊與目標右邊齊平
topEqualToView(<UIView>) //頂邊與目標頂邊齊平
bottomEqualToView(<UIView>) //底邊與目標底邊齊平
centerXEqualToView(<UIView>) //中心點X坐標與目標中心點X坐標相同
centerYEqualToView(<UIView>) //中心點Y坐標與目標中心點Y坐標相同
widthEqualToHeight() //自身寬高相等
heightEqualToWidth() //自身高寬相等
leftSpaceToView(<UIView>,<CGFloat>) //左邊到目標view的距離,當目標是父視圖脑蠕,參照的是目標的左邊(同邊)跪削,否則份招,參照的是目標的右邊(對邊)
rightSpaceToView(<UIView>,<CGFloat>) //右邊到目標view的距離(同理)
topSpaceToView(<UIView>,<CGFloat>) //頂邊到目標view的距離(同理)
bottomSpaceToView(<UIView>,<CGFloat>) //底邊到目標view的距離(同理)
spaceToSuperView(UIEdgeInsetsMake(top, left, bottom, right)) //快捷設置到父視圖的上左下右邊距
centerXIs(<CGFloat>) //設置中心點X坐標
centerYIs(<CGFloat>) //設置中心點Y坐標
xIs(<CGFloat>) //原點x坐標
yIs(<CGFloat>) //原點y坐標
widthIs(<CGFloat>) //寬度
heightIs(<CGFloat>) //高度
maxWidthIs(<CGFloat>) //最大寬度
maxHeightIs(<CGFloat>)? //最大高度
minWidthIs(<CGFloat>) //最小寬度
minHeightIs(<CGFloat>) //最小高度
widthRatioToView(<UIView>,<CGFloat>) //寬度是目標寬度的多少倍
heightRatioToView(<UIView>,<CGFloat>) //高度是目標高度的多少倍
autoHeightRatio(<CGFloat>) //自身高寬比;特別的狞甚,label傳入0,可實現(xiàn)文字高度的自適應
autoWidthRatio(<CGFloat>) //自身的寬高比
當需要cell自適應的時候時候, 需要在cell里面添加完約束之后添加
//添加這句話目的就是為了cell高度自適應, 根據(jù)誰的底部進行適配高度就好了,lable1是cell最底部的視圖, 10, 距離底部多少
? ? [self setupAutoHeightWithBottomView:self.lable1 bottomMargin:10];
當賦值之后需要更改某一個視圖的frame時, 只需要
?[self updateLayout];更新約束
計算cell高度
- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{
? ? return [self cellHeightForIndexPath:indexPath cellContentViewWidth:[UIScreen mainScreen].bounds.size.width tableView:tableView];
}
/**?
?* 設置類似collectionView效果的固定間距自動寬度浮動子view?
?* viewsArray? ? ? : 需要浮動布局的所有視圖
?* perRowItemsCount : 每行顯示的視圖個數(shù)
?* verticalMargin? : 視圖之間的垂直間距
?* horizontalMargin : 視圖之間的水平間距
?* vInset? ? ? ? ? : 上下縮進值
?* hInset? ? ? ? ? : 左右縮進值
?*/
- (void)setupAutoWidthFlowItems:(NSArray*)viewsArray withPerRowItemsCount:(NSInteger)perRowItemsCount verticalMargin:(CGFloat)verticalMargin horizontalMargin:(CGFloat)horizontalMagin verticalEdgeInset:(CGFloat)vInset horizontalEdgeInset:(CGFloat)hInset;
/**?
?* 設置類似collectionView效果的固定寬度帶自動間距浮動子view?
?* viewsArray? ? ? : 需要浮動布局的所有視圖
?* perRowItemsCount : 每行顯示的視圖個數(shù)
?* verticalMargin? : 視圖之間的垂直間距
?* vInset? ? ? ? ? : 上下縮進值
?* hInset? ? ? ? ? : 左右縮進值
?*/
- (void)setupAutoMarginFlowItems:(NSArray*)viewsArray withPerRowItemsCount:(NSInteger)perRowItemsCount itemWidth:(CGFloat)itemWidth verticalMargin:(CGFloat)verticalMargin verticalEdgeInset:(CGFloat)vInset horizontalEdgeInset:(CGFloat)hInset;
######UIScrollewView
ScrollerView的高度需要寫死, 而constentSize需要根據(jù)最后一個view進行自適應就可以了
/** 設置scrollview內(nèi)容豎向自適應 */把最后一個view寫進去就好了
- (void)setupAutoContentSizeWithBottomView:(UIView*)bottomView bottomMargin:(CGFloat)bottomMargin;
/** 設置scrollview內(nèi)容橫向自適應 */把最右邊的view寫進去就好了
- (void)setupAutoContentSizeWithRightView:(UIView*)rightView rightMargin:(CGFloat)rightMargin;
############UIButton-----寬度自適應
/*
?* 設置button根據(jù)單行文字自適應
?* hPadding:左右邊距
?*/
- (void)setupAutoSizeWithHorizontalPadding:(CGFloat)hPadding buttonHeight:(CGFloat)buttonHeight;