国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > iOS > 正文

iOS開發(fā)中簡單實(shí)用的幾個(gè)小技巧

2019-10-21 18:50:34
字體:
供稿:網(wǎng)友

前言

本文記錄了在iOS開發(fā)過程中所遇到的小知識(shí)點(diǎn),以及一些技巧,下面話不多說,來看看詳細(xì)的介紹。

技巧1:UIButton圖片與文字默認(rèn)是左右排列,如何實(shí)現(xiàn)右左排列?

解決技巧:

button.transform = CGAffineTransformMakeScale(-1.0, 1.0);button.titleLabel.transform = CGAffineTransformMakeScale(-1.0, 1.0);button.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);

ios開發(fā)小技巧,ios簡單開發(fā),ios小技巧

技巧2:設(shè)置導(dǎo)航欄透明,title與BarButtonItem不透明

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];self.navigationController.navigationBar.translucent = YES;

ios開發(fā)小技巧,ios簡單開發(fā),ios小技巧

技巧3:設(shè)置導(dǎo)航欄無邊框

self.navigationController.navigationBar.shadowImage = [UIImage new];

ios開發(fā)小技巧,ios簡單開發(fā),ios小技巧

技巧4: 隨視圖的滾動(dòng)導(dǎo)航欄隱藏與顯示(一句代碼即可)

self.navigationController.hidesBarsOnSwipe = Yes;

ios開發(fā)小技巧,ios簡單開發(fā),ios小技巧

技巧5:簡單好用的獲取當(dāng)前時(shí)間戳

 //時(shí)間戳 time_t now; time(&now); NSLog(@"---%ld",now);

ios開發(fā)小技巧,ios簡單開發(fā),ios小技巧

技巧6:只設(shè)置UIView的左上角和右上角的圓角 (四個(gè)圓角位置都可以選擇)

 UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 100)]; blueView.backgroundColor = [UIColor blueColor]; [self.view addSubview: blueView];  /*設(shè)置圓角位置的枚舉參數(shù)  UIRectCornerTopLeft  = 1 << 0,  UIRectCornerTopRight = 1 << 1,  UIRectCornerBottomLeft = 1 << 2,  UIRectCornerBottomRight = 1 << 3,  UIRectCornerAllCorners = ~0UL  */ UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:blueView.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(20.0, 20.0)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = blueView.bounds; maskLayer.path = maskPath.CGPath; blueView.layer.mask = maskLayer;

ios開發(fā)小技巧,ios簡單開發(fā),ios小技巧

技巧7: 加載UIWebView后禁止用戶復(fù)制剪切

// 控制器實(shí)現(xiàn)此方法- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{ if (action == @selector(copy:) ||  action == @selector(paste:)||  action == @selector(cut:)) {  return NO; } return [super canPerformAction:action withSender:sender];}

技巧8:跳轉(zhuǎn)控制器隱藏tabbar一個(gè)一勞永逸的方法

// 創(chuàng)建一個(gè)Nav基類 重寫pushViewController:方法 如下:-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { viewController.hidesBottomBarWhenPushed = YES; [super pushViewController:viewController animated:animated];}

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的這些小技巧對(duì)各位iOS開發(fā)者們能有所幫助,如果有疑問大家可以留言交流。小編還會(huì)陸續(xù)更新關(guān)于iOS相關(guān)技巧的文章,請(qǐng)繼續(xù)關(guān)注VEVB武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到IOS開發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 凉山| 郴州市| 宽城| 远安县| 尉氏县| 合江县| 永靖县| 什邡市| 桂东县| 盈江县| 临安市| 泗阳县| 土默特右旗| 博客| 宁阳县| 镶黄旗| 西平县| 进贤县| 苏尼特右旗| 平江县| 新密市| 皋兰县| 东乌| 泰顺县| 钟山县| 荣昌县| 呼图壁县| 阆中市| 左贡县| 金昌市| 九龙坡区| 浮山县| 靖安县| 平潭县| 自贡市| 望奎县| 苏尼特右旗| 高清| 建昌县| 伊金霍洛旗| 孟州市|