iOS UI技巧(持續(xù)更新)

  1. 清空所以子視圖
[view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  1. 使tableView的grouped類型的組頭出現(xiàn)了一段默認(rèn)的高度,取消方法
//1.設(shè)置tableHeaderView的Frame
 CGRect frame = CGRectMake(0, 0, 0, 0.1);
    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:frame];
//2.把tableView整體進(jìn)行偏移
 self.tableView.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);
//3.針對沒有頭部視圖的,只需要實(shí)現(xiàn)這個代理方法
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1;
}

3.iOS截取UIView,保存為Image

#pragma mark 生成image
- (UIImage *)makeImageWithView:(UIView *)view
{
    CGSize size = bgView.bounds.size;
    /*
     下面方法,
     第一個參數(shù)表示區(qū)域大小。
     第二個參數(shù)表示是否是非透明的。如果需要顯示半透明效果,需要傳NO,否則傳YES。
     第三個參數(shù)就是屏幕密度了,關(guān)鍵就是第三個參數(shù)。
     */
    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
  1. 改變pushViewCollectionView的跳轉(zhuǎn)樣式
/*
方法一:
注意:使用view的layer屬性,要在頭文件里導(dǎo)入
#import <QuartzCore/QuartzCore.h>
和添加QuartzCore.framework
*/
transition.type = kCATransitionFade;//類型(具體類型看源碼)
transition.subtype = kCATransitionFromRight;//從右邊push(具體看源碼)
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

/*
方法二:
*/
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:gradeVc];
nc.modalTransitionStyle = UIModalPresentationNone;
[self.window.rootViewController presentViewController:nc animated:YES completion:nil];
  1. 隨機(jī)顏色的宏定義
#define random(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]
#define randomColor random(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,376評論 4 61
  • 一、婚姻 就在剛才,我接到了我媽的電話。 一陣噓寒問暖過后,老媽按耐不住直接切入了主題: 找女朋友了沒?你看鄰居小...
    Firday閱讀 583評論 0 0
  • 使用印象筆記有很長時間了,累積了幾百篇筆記,但每天見面卻沒有仔細(xì)地研究過,也就談不上高效使用和最大化它的功效了。閱...
    kamous閱讀 2,086評論 6 7
  • “XXX” “到。” 大學(xué)課堂特別的風(fēng)景線,一聲散漫的“到”或隨意的舉手示意,為了證明“我在?!笔聦?shí)往往,我人在,...
    woooooooooood閱讀 286評論 0 2

友情鏈接更多精彩內(nèi)容