iOS開發基礎知識 碎片24

2021-09-08 19:09:45 字數 3679 閱讀 3757

ios開發基礎知識--碎片24

1:相容字型大小6plue跟它以下的區別

#define font_compatible_screen_offset(_fontsize_)  [uifont systemfontofsize:(_fontsize_ *([uiscreen mainscreen].scale) / 2)]
在iphone4~6中,縮放因子scale=2;在iphone6+中,縮放因子scale=3

運用時:

mylabel.font=font_compatible_screen_offset(15);
擴充套件:畫一畫素的巨集

#define single_line_width           (1 / [uiscreen mainscreen].scale)

#define single_line_adjust_offset ((1 / [uiscreen mainscreen].scale) / 2)

運用時:

cgfloat xpos = 5;

uiview *view = [[uiview alloc] initwithframe:cgrect(x - single_line_adjust_offset, 0, single_line_width, 100)];

there was an internal api error.

build settings中的packaging的product name設定成中文

3:xcode證書存放路徑

資源庫/mobiledevice/provisioning profiles
4:使用第三方rdvtabbarcontroller底部tab時

若要隱藏時把動畫關掉,就不會出現一閃的情況

//隱藏底部選單

[[self rdv_tabbarcontroller] settabbarhidden:yes animated:no];

} [[self rdv_tabbarcontroller] settabbarhidden:no animated:no];

}

5:masonry一些其它內容

a:make.equalto 或 make.greaterthanorequalto (至多) 或 make.lessthanorequalto(至少)

make.left.greaterthanorequalto(label);

make.left.greaterthanorequalto(label.mas_left);

//width >= 200 && width <= 400

make.width.greaterthanorequalto(@200);

make.width.lessthanorequalto(@400)

b:masequalto 和 equalto 區別:masequalto 比equalto多了型別轉換操作,一般來說,大多數時候兩個方法都是 通用的,但是對於數值元素使用mas_equalto。對於物件或是多個屬性的處理,使用equalto。特別是多個屬性時,必須使用equalto

c:一些簡便賦值

// make top = superview.top + 5, left = superview.left + 10,

// bottom = superview.bottom - 15, right = superview.right - 20

make.edges.equalto(superview).insets(uiedgeinsetsmake(5, 10, 15, 20))

// make width and height greater than or equal to titlelabel

make.size.greaterthanorequalto(titlelabel)

// make width = superview.width + 100, height = superview.height - 50

make.size.equalto(superview).sizeoffset(cgsizemake(100, -50))

// make centerx = superview.centerx - 5, centery = superview.centery + 10

make.center.equalto(superview).centeroffset(cgpointmake(-5, 10))

d:and關鍵字運用

make.left.right.and.bottom.equalto(superview); 

make.top.equalto(otherview);

e:優先;優先權(.priority,.priorityhigh,.prioritymedium,.prioritylow)

`.priority`允許您指定乙個確切的優先順序

`.priorityhigh`等價於uilayoutprioritydefaulthigh

`.prioritymedium`介於高跟低之間

`.prioritylow` 等價於uilayoutprioritydefaultlow

例項:make.left.greaterthanorequalto(label.mas_left).with.prioritylow();

make.top.equalto(label.mas_top).with.priority(600);

g:使用mas_makeconstraints建立constraint後,你可以使用區域性變數或屬性來儲存以便下次引用它;如果建立多個constraints,你可以採用陣列來儲存它們

// 區域性或者全域性

@property (nonatomic, strong) masconstraint *topconstraint;

// 建立約束並賦值

[view1 mas_makeconstraints:^(masconstraintmaker *make) ];

// 過後可以直接訪問self.topconstraint

[self.topconstraint uninstall];

h:mas_updateconstraints更新約束,有時你需要更新constraint(例如,動畫和除錯)而不是建立固定constraint,可以使用mas_updateconstraints方法

- (void)updateconstraints ];

//呼叫父updateconstraints

[super updateconstraints];

}

i:mas_remakeconstraints更新約束,mas_remakeconstraints與mas_updateconstraints比較相似,都是更新constraint。不過,mas_remakeconstraints是刪除之前constraint,然後再新增新的constraint(適用於移動動畫);而mas_updateconstraints只是更新constraint的值。

- (void)changebuttonposition  else 

}];}

IOS開發基礎知識 碎片32

1 動畫屬性uiviewanimationoptions說明 a 常規動畫屬性設定 可以同時選擇多個進行設定 uiviewanimationoptionlayoutsubviews 動畫過程中保證子檢視跟隨運動。uiviewanimationoptionallowuserinteraction 動畫...

IOS開發基礎知識 碎片43

1 增加手勢進行左劃效果,針對檢視並修改其中乙個的座標,選單用隱藏跟顯示 property strong,nonatomic uiswipegesturerecognizer recognizer self.recognizer uiswipegesturerecognizer alloc init...

iOS開發基礎知識

在ios中,你能看得見摸得著的東西基本上都是uiview,比如乙個按鈕 乙個文字標籤 乙個文字輸入框 乙個圖示等等,這些都是uiview。其實uiview之所以能顯示在螢幕上,完全是因為它內部的乙個圖層 在建立uiview物件時,uiview內部會自動建立乙個圖層 即calayer物件 通過uivi...