不規則瀑布流

2021-07-06 09:01:28 字數 3197 閱讀 9682

封裝的layout

#import #import @protocol waterlayoutdelegate @required

- (cgsize)collectionview:(uicollectionview *)collectionview

layout:(uicollectionviewlayout *)collectionviewlayout

sizeforitematindexpath:(nsindexpath *)indexpath;

@end

@inte***ce wjy_wate***lllayout : uicollectionviewlayout

@property (nonatomic, assign) iddelegate;

// 行數

@property (nonatomic, assign) nsinteger linecount;

// 水平間距

@property (nonatomic, assign) cgfloat verticalspacing;

// 垂直間距

@property (nonatomic, assign) cgfloat horizontalspacing;

@property (nonatomic, assign) uiedgeinsets sectioninset;

@end

#import "wjy_wate***lllayout.h"

@inte***ce wjy_wate***lllayout()

@property (nonatomic, retain) nsmutablearray *heights;

@property (nonatomic, retain) nsmutablearray *originx;

@property (nonatomic, retain) nsmutabledictionary *itemsarrange;

@property (nonatomic, retain) nsmutabledictionary *itemsinitialarrange;

@end

@implementation wjy_wate***lllayout

#pragma mark - 重寫,應 始終呼叫子類

- (void)preparelayout

// 調轉系統的協議方法 並設定**

self.delegate = (id)self.collectionview.delegate;

self.itemsarrange = [nsmutabledictionary dictionary];

self.itemsinitialarrange = [nsmutabledictionary dictionary];

[self initallarrays];

for (nsinteger i = 0; i < cellcount; i++)

}#pragma 初始化所以陣列

- (void)initallarrays

else

// 把得到的點加到 x陣列中

[self.originx addobject:[nsnumber numberwithdouble: oringin_x]];

}}#pragma mark - itme設定

- (void)layoutforitematindexpath:(nsindexpath *)indexpath

#pragma mark - 子類必須重寫此方法並使用它來返回的寬度和高度的檢視的內容。這些值表示的寬度和高度的所有內容,檢視使用此資訊來配置其自身內容的大小,以便滾動。

- (cgsize)collectionviewcontentsize

#pragma mark - 設定布局資訊

- (uicollectionviewlayoutattributes *)layoutattributesforitematindexpath:(nsindexpath *)indexpath

cgrect rect = cgrectfromstring(rectstr);

attributes.frame = rect;

break;

}return attributes;

}#pragma mark - 重新自定義layout

// layout初始化方法

uicollectionviewlayoutattributes *attributes = [uicollectionviewlayoutattributes layoutattributesforcellwithindexpath:itemindexpath];

nsarray *keyarr = self.itemsarrange.allkeys;

for (nsstring *rectstr in keyarr)

cgrect rect = cgrectfromstring(rectstr);

attributes.frame = rect;

break;

}return attributes;

}#pragma mark - 布局屬性返回陣列 檢視在給定矩形

- (nsarray *)layoutattributesforelementsinrect:(cgrect)rect

}return attributes;

}# pragma mark - 獲取低行高

- (nsinteger)getlowerheightrowindex:(nsmutablearray *)height

nsinteger index = 0;

cgfloat heightest = [height[0] doublevalue];

for (nsinteger i = 1; i < height.count; i++)

return index;

}# pragma mark - 獲取高度

- (cgfloat)getheightest:(nsmutablearray *)height

cgfloat heightest = self.sectioninset.top;

// 遍歷最高點

for (nsinteger i = 0; i < height.count; i++)

return heightest;

}@end

不規則遮罩

不規則遮罩用不規則png去做遮罩,但是需要加個filter 對乙個displayobject應用乙個不規則遮罩可以有兩種方法 displayobjecta為被遮罩物件 displayobjectb是遮罩物件 1.用於做遮罩的displayobjectb用其graphic 畫出不規則的圖形,然後被遮罩...

MFC不規則視窗

直接在onpaint 函式裡新增語句 setwindowlong m hwnd,gwl exstyle,getwindowlong m hwnd,gwl exstyle ws ex layered setlayeredwindowattributes rgb 255,255,255 0,lwa co...

OSPF不規則區域

一 實驗拓撲 二 實驗要求 解決以上實驗拓撲 ospf 的不規則區域問題 三 實驗步驟 1 配置位址 r1的配置 r1 loopback0 ip add 1.1.1.1 24 r1 gigabitethernet0 0 0 ip add 12.1.1.1 24 r2的配置 r2 gigabiteth...