IOS開發基礎知識 碎片43

2021-09-09 02:01:05 字數 2315 閱讀 6886

1:增加手勢進行左劃效果,針對檢視並修改其中乙個的座標,選單用隱藏跟顯示

@property(strong,nonatomic)uiswipegesturerecognizer *recognizer;

self.recognizer =[[ uiswipegesturerecognizer alloc ] initwithtarget:self action:@selector (handleswipefrom:)];

[self.recognizer setdirection:(uiswipegesturerecognizerdirectionleft)];

[self addgesturerecognizer :self.recognizer];

- (void)handleswipefrom:( uiswipegesturerecognizer *)sender];

[self.valuelabel layoutifneeded];

}else

]; [self.valuelabel layoutifneeded];

}}

2:屬性名以new開頭解決方式

@property (nonatomic,copy) nsstring *new_passwd;  

像上面這樣寫法會報錯,可以替換成

@property (nonatomic,copy,getter = thenewpasswd) nsstring *new_passwd;

3:單例類一些注意事項

如果allocwithzone裡面的**不寫,用以下三種建立的例項還是三種,不符合我們對單例的運用,當然如果你只針對[hltestobject sharedinstance]進行例項化時,就是一直滿足;把初始化的屬性物件放在sharedinstance裡面,如果放在init裡面進行初始化也會出現不一樣的情景;

hltestobject *objct1 =[hltestobject sharedinstance];

nslog(

@"%@

",objct1);

hltestobject *objc2 =[[hltestobject alloc] init];

nslog(

@"%@

",objc2);

hltestobject *objc3 = [hltestobject new

];nslog(

@"%@

",objc3);

宣告屬性:

@property (assign, nonatomic)   int

height;

@property (strong, nonatomic)   nsobject  *object

;@property (strong, nonatomic)   nsmutablearray  *arraym;

**內容:

static hltestobject *instance =nil;

+(instancetype)sharedinstance

);    

return

instance;

}+ (instancetype)allocwithzone:(struct _nszone *)zone

);    

return

instance;

}- (nsstring *)description

4:uitextfield實現左側空出一定的邊距

就是通過uitextfield的leftview來實現的,同時要設定leftviewmode。

如果設定左右邊距,需要再加上rightview功能

-(void)settextfieldleftpadding:(uitextfield *)textfield forwidth:(cgfloat)leftwidth

5:uicollectionview非同步載入的例項

-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath

); }

});}

return

cell;

}

IOS開發基礎知識 碎片32

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

iOS開發基礎知識 碎片24

ios開發基礎知識 碎片24 1 相容字型大小6plue跟它以下的區別 define font compatible screen offset fontsize uifont systemfontofsize fontsize uiscreen mainscreen scale 2 在iphone...

iOS開發基礎知識

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