欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

ios開發(fā)字符串,ios字符串包含某個字符串

ios開發(fā) 怎么改變字符串某幾個字的字體

法一:(自定義視圖的方法,一般人也會采用這樣的方式)

創(chuàng)新互聯(lián)建站始終堅持【策劃先行,效果至上】的經(jīng)營理念,通過多達十多年累計超上千家客戶的網(wǎng)站建設總結了一套系統(tǒng)有效的全網(wǎng)營銷解決方案,現(xiàn)已廣泛運用于各行各業(yè)的客戶,其中包括:辦公空間設計等企業(yè),備受客戶好評。

就是在導航向上添加一個titleView,可以使用一個label,再設置label的背景顏色透明,字體什么的設置就很簡單了。

//自定義標題視圖

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];

titleLabel.backgroundColor = [UIColor grayColor];

titleLabel.font = [UIFont boldSystemFontOfSize:20];

titleLabel.textColor = [UIColor greenColor];

titleLabel.textAlignment = NSTextAlignmentCenter;

titleLabel.text = @"新聞";

self.navigationItem.titleView = titleLabel;

方法二:(在默認顯示的標題中直接修改文件的大小和顏色也是可以的)

[self.navigationController.navigationBar setTitleTextAttributes:

@{NSFontAttributeName:[UIFont systemFontOfSize:19],

NSForegroundColorAttributeName:[UIColor redColor]}];

方式二相對于方式一而言更加簡單方便

iOS開發(fā)中判斷空字符串的幾種方法

第一種方式是使用NSScanner:

1. 整形判斷

- (BOOL)isPureInt:(NSString *)string{

NSScanner* scan = [NSScanner scannerWithString:string];

int val;

return [scan scanInt:val] [scan isAtEnd];

}

2.浮點形判斷:

- (BOOL)isPureFloat:(NSString *)string{

NSScanner* scan = [NSScanner scannerWithString:string];

float val;

return [scan scanFloat:val] [scan isAtEnd];

}

第二種方式是使用循環(huán)判斷

- (BOOL)isPureNumandCharacters:(NSString *)text

{

for(int i = 0; i [text length]; ++i) {

int a = [text characterAtIndex:i];

if ([self isNum:a]){

continue;

} else {

return NO;

}

}

return YES;

}

或者 C語言中常用的方式.

- (BOOL)isAllNum:(NSString *)string{

unichar c;

for (int i=0; istring.length; i++) {

c=[string characterAtIndex:i];

if (!isdigit(c)) {

return NO;

}

}

return YES;

}

第三種方式則是使用NSString的trimming方法

- (BOOL)isPureNumandCharacters:(NSString *)string

{

string = [string stringByTrimmingCharactersInSet;[NSCharacterSet decimalDigitCharacterSet]];

if(string.length 0)

{

return NO;

}

return YES;

}

iOS開發(fā)中遇到的小問題-----總結

1、統(tǒng)一收鍵盤的方法

[[[UIApplication sharedApplication] keyWindow] endEditing:YES];

2、提示框

BBAlertView *alert = [[BBAlertView alloc] initWithStyle:BBAlertViewStyleDefault

Title:@"刪除訂單"

message:@"是否刪除訂單,"

customView:nil

delegate:self

cancelButtonTitle:L(@"取消")

otherButtonTitles:L(@"確認")];

[alert setCancelBlock:^{

}];

[alert setConfirmBlock:^{

[self orderDidRemovePressDown:tempDic Index:index.section];

}];

[alert show];

3、圖片的自適應功能

self.brandImage.contentMode = UIViewContentModeScaleAspectFit;

4、cocoaPods清除緩存問題

$ sudo rm -fr ~/.cocoapods/repos/master

$ pod setup

5、設置顯示鍵盤的樣式

textView.keyboardType =UIKeyboardTypeDefault;

//設置鍵盤右下角為完成(中文輸入法下)

textView.returnKeyType=UIReturnKeyDone;

6、輸出當前時間

NSDateFormatter * dateFormatter=[[NSDateFormatter alloc]init];

[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];

NSLog(@"當前毫秒時間1==%@",[dateFormatter stringFromDate:[NSDate date]]);

7、顯示兩秒然后消失

UILabel * lab=[[UILabel alloc]initWithFrame:CGRectMake(60,Main_Screen_Height-64-49-60, Main_Screen_Width-120, 50)];

lab.backgroundColor=[UIColor grayColor];

ViewRadius(lab, 20);

lab.textAlignment=NSTextAlignmentCenter;

lab.text=@"請先進行實名制驗證";

[self.view addSubview:lab];

[UILabel animateWithDuration:2 animations:^{

lab.alpha=0;

}completion:^(BOOL finished) {

[lab removeFromSuperview];

}];

8、設置placeholder屬性的大小和顏色

[_phoneFie setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];

[_phoneFie setValue:[UIFont boldSystemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];

_phoneFie.returnKeyType=UIReturnKeyDone;

9、設置cell的交互完全不可以使用

//[cellTwo setUserInteractionEnabled:NO];

//設置cell不可以點擊,但是上面的子控件可以交互

cellTwo.selectionStyle=UITableViewCellSelectionStyleNone;

10、將textField的placeholder 屬性的字體向右邊移動5

_field.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10*Width_375, _field.frame.size.height)];

_field.leftViewMode = UITextFieldViewModeAlways;

11、開新線程使按鈕上的時間變化

-(void)startTime{

__block int timeout=60; //倒計時時間

UIButton * btn=(UIButton *)[self.view viewWithTag:1000];

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);

dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒執(zhí)行

dispatch_source_set_event_handler(_timer, ^{

if(timeout=0){

dispatch_source_cancel(_timer);

dispatch_async(dispatch_get_main_queue(), ^{

[btn setTitle:@"發(fā)送驗證碼" forState:UIControlStateNormal];

btn.enabled = YES;

});

}else{

//? int minutes = timeout / 60;

int miao = timeout % 60;

if (miao==0) {

miao = 60;

}

NSString *strTime = [NSString stringWithFormat:@"%.2d", miao];

dispatch_async(dispatch_get_main_queue(), ^{

[btn setTitle:[NSString stringWithFormat:@"剩余%@秒",strTime] forState:UIControlStateNormal];

btn.enabled = NO;

});

timeout--;

}

});

dispatch_resume(_timer);

}

12、隱藏TableView 中多余的行

UIView * view=[[UIView alloc]initWithFrame:CGRectZero];

[_tabelView setTableFooterView:view];

13、UIView添加背景圖片

UIImage * image=[UIImage imageNamed:@"friend750"];

headSeV.layer.contents=(id)image.CGImage;

14、UITableView取消選中狀態(tài)

[tableView deselectRowAtIndexPath:indexPath animated:YES];// 取消選中

15、帶屬性的字符串

NSFontAttributeName? 字體

NSParagraphStyleAttributeName? 段落格式

NSForegroundColorAttributeName? 字體顏色

NSBackgroundColorAttributeName? 背景顏色

NSStrikethroughStyleAttributeName 刪除線格式

NSUnderlineStyleAttributeName? ? ? 下劃線格式

NSStrokeColorAttributeName? ? ? ? 刪除線顏色

NSStrokeWidthAttributeName 刪除線寬度

NSShadowAttributeName? 陰影

1.? 使用實例

UILabel *testLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 320, 30)];

testLabel.backgroundColor = [UIColor lightGrayColor];

testLabel.textAlignment = NSTextAlignmentCenter;

NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"今天天氣不錯呀"];

[AttributedStr addAttribute:NSFontAttributeName

value:[UIFont systemFontOfSize:16.0]

range:NSMakeRange(2, 2)];

[AttributedStr addAttribute:NSForegroundColorAttributeName

value:[UIColor redColor]

range:NSMakeRange(2, 2)];

testLabel.attributedText = AttributedStr;

[self.view addSubview:testLabel];

16、加大按鈕的點擊范圍

把UIButton的frame 設置的大一些,然后給UIButton設置一個小些的圖片

[tmpBtn setImageEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];

// 注意這里不能用setBackgroundImage

[tmpBtn setImage:[UIImage imageNamed:@"testBtnImage"] forState:UIControlStateNormal];

17、//避免self的強引用

__weak ViewController *weakSelf = self;

18、//類別的創(chuàng)建

command +n ——Objective-C File———(File Type? 選擇是類別還是擴展)———(Class? 選擇為哪個控件寫類別)

19、修改UITableview 滾動條顏色的方法

self.tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;

20、利用UIWebView顯示pdf文件

webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];

[webView setDelegate:self];

[webView setScalesPageToFit:YES];

[webViewsetAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];

[webView setAllowsInlineMediaPlayback:YES];

[self.view addSubview:webView];

NSString *pdfPath = [[NSBundle mainBundle]pathForResource:@"ojc" ofType:@"pdf"];

NSURL *url = [NSURLfileURLWithPath:pdfPath];

NSURLRequest *request = [NSURLRequestrequestWithURL:url

cachePolicy:NSURLRequestUseProtocolCachePolicy

timeoutInterval:5];

[webView loadRequest:request];

21、將plist文件中的數(shù)據(jù)賦給數(shù)組

NSString *thePath = [[NSBundle mainBundle]pathForResource:@"States" ofType:@"plist"];

NSArray *array = [NSArrayarrayWithContentsOfFile:thePath];

22、隱藏狀態(tài)欄

[[UIApplication shareApplication]setStatusBarHidden: YES animated:NO];

23、給navigation? Bar? 設置title顏色

UIColor *whiteColor = [UIColor whiteColor];

NSDictionary *dic = [NSDictionary dictionaryWithObject:whiteColor forKey:NSForegroundColorAttributeName];

[self.navigationController.navigationBar setTitleTextAttributes:dic];

24、使用AirDrop 進行分享

NSArray *array = @[@"test1", @"test2"];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:array applicationActivities:nil];

[self presentViewController:activityVC animated:YES

completion:^{

NSLog(@"Air");

}];

25、把tableview里面Cell的小對勾的顏色改成別的顏色

_mTableView.tintColor = [UIColor redColor];

26、UITableView去掉分割線

_tableView.separatorStyle = NO;

27、正則判斷手機號碼地址格式

- (BOOL)isMobileNumber:(NSString *)mobileNum {

//? ? 電信號段:133/153/180/181/189/177

//? ? 聯(lián)通號段:130/131/132/155/156/185/186/145/176

//? ? 移動號段:134/135/136/137/138/139/150/151/152/157/158/159/182/183/184/187/188/147/178

//? ? 虛擬運營商:170

NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|7[06-8])\\d{8}$";

NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];

return [regextestmobile evaluateWithObject:mobileNum];

}

28、控制交易密碼位數(shù)

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{

if (textField.text.length =6){

[MBProgressHUD showMessage:@"密碼為6位" afterDelay:1.8];

return NO;

}

return YES;

}

29、判斷是不是空

if ([real_name isKindOfClass:[NSNull class]] ) {

return NO;}

30、點擊號碼撥打電話

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://400966220"]];

31、控制UITabbar的選擇哪一個

[self.tabBarController setSelectedIndex:1];

32、獲取當前App的版本號

NSDictionary?*infoDictionary?=?[[NSBundle?mainBundle]?infoDictionary];

CFShow(infoDictionary);

//?app名稱

NSString?*app_Name?=?[infoDictionary?objectForKey:@"CFBundleDisplayName"];

//?app版本

NSString?*app_Version?=?[infoDictionary?objectForKey:@"CFBundleShortVersionString"];

//?app?build版本

NSString?*app_build?=?[infoDictionary?objectForKey:@"CFBundleVersion"];

33、蘋果app權限NSPhotoLibraryUsageDescriptionApp需要您的同意,才能訪問相冊NSCameraUsageDescriptionApp需要您的同意,才能訪問相機NSMicrophoneUsageDescriptionApp需要您的同意,才能訪問麥克風NSLocationUsageDescriptionApp需要您的同意,才能訪問位置NSLocationWhenInUseUsageDescriptionApp需要您的同意,才能在使用期間訪問位置NSLocationAlwaysUsageDescriptionApp需要您的同意,才能始終訪問位置NSCalendarsUsageDescriptionApp需要您的同意,才能訪問日歷NSRemindersUsageDescriptionApp需要您的同意,才能訪問提醒事項NSMotionUsageDescriptionApp需要您的同意,才能訪問運動與健身NSHealthUpdateUsageDescriptionApp需要您的同意,才能訪問健康更新NSHealthShareUsageDescriptionApp需要您的同意,才能訪問健康分享NSBluetoothPeripheralUsageDescriptionApp需要您的同意,才能訪問藍牙NSAppleMusicUsageDescriptionApp需要您的同意,才能訪問媒體資料庫

34、控件設置邊框

_describText.layer.borderColor = [[UIColor colorWithRed:215.0 / 255.0 green:215.0 / 255.0 blue:215.0 / 255.0 alpha:1] CGColor];

_describText.layer.borderWidth = 1.0;

_describText.layer.cornerRadius = 4.0;

_describText.clipsToBounds = YES;

35、//隱藏電池條的方法

-(BOOL)prefersStatusBarHidden{

return YES;

}

36、延時操作

[NSThread sleepForTimeInterval:2];

方法二:

[self performSelector:@selector(delayMethod) withObject:nil afterDelay:1.5];

37、系統(tǒng)風火輪:

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; //隱藏

38、//didSelectRowAtIndexPath:方法里面找到當前的Cell

AssessMentCell * cell = [tableView cellForRowAtIndexPath:indexPath];

39、navigation上返回按鈕的顏色以及返回按鈕后面文字去掉

//返回按鈕后邊文字去掉

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)

forBarMetrics:UIBarMetricsDefault];

//設置左上角返回按鈕的顏色

self.navigationController.navigationBar.tintColor = UIColorFromRGB(0x666666);

40、lineBreakMode //設置文字過長時的顯示格式

label.lineBreakMode = NSLineBreakByCharWrapping;以字符為顯示單位顯

示,后面部分省略不顯示。

label.lineBreakMode = NSLineBreakByClipping;剪切與文本寬度相同的內(nèi)

容長度,后半部分被刪除。

label.lineBreakMode = NSLineBreakByTruncatingHead;前面部分文字

以……方式省略,顯示尾部文字內(nèi)容。

label.lineBreakMode = NSLineBreakByTruncatingMiddle;中間的內(nèi)容

以……方式省略,顯示頭尾的文字內(nèi)容。

label.lineBreakMode = NSLineBreakByTruncatingTail;結尾部分的內(nèi)容

以……方式省略,顯示頭的文字內(nèi)容。

label.lineBreakMode = NSLineBreakByWordWrapping;以單詞為顯示單位顯

示,后面部分省略不顯示。

ios開發(fā) 字符串

+ (id)stringWithContentsOfFile:(NSString *)path usedEncoding:(NSStringEncoding *)enc error:(NSError **)error;

是自動判斷encode,如果打開成功,把encode放在enc 里,返回給調(diào)用者。

聲明一個NSStringEncoding 類型(其實就是NSUInteger)然后送指針給方法就是了。例如

NSStringEncoding?enc;

NSString?*string?=?[NSString?stringWithContentsOfFile:path?usedEncoding:enc?error:nil];

成功之后你可以檢查 enc 以確定 string 的編碼。

而另外一個:

+ (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error;

則是你自己知道編碼,明確要求用這種編碼來讀取文件內(nèi)容。

新聞標題:ios開發(fā)字符串,ios字符串包含某個字符串
網(wǎng)頁URL:http://chinadenli.net/article28/dsessjp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷響應式網(wǎng)站軟件開發(fā)服務器托管網(wǎng)站內(nèi)鏈網(wǎng)站設計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化