2015-09-25 107 views
-2

我想改變字體樣式& UITextView的家庭。實際上我會從picker中選擇字體系列,然後更改UITextView的字體系列。請告訴我如何做到這一點?如何在iOS中更改textview的字體系列和樣式?

+0

顯示您的選擇器選擇代碼 –

+0

我還沒有爲字體編寫任何代碼。我需要代碼 – Techiee

+1

編寫代碼以創建選取器,然後創建字體數據並從選擇器中選擇在textview中應用所選字體,然後如果您面對任何問題都顯示你的代碼。 –

回答

0

嘗試一下本作顯示選擇器

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ 
UILabel* labelFontName = (UILabel*)view; 
if (!labelFontName){ 
    labelFontName = [[UILabel alloc] init]; 
    labelFontName .adjustsFontSizeToFitWidth = YES; 
    labelFontName .TextAlignment = NSTextAlignmentCenter; 
    labelFontName .font = [UIFont fontWithName:@"Arial" size:18]; 
} 
NSString *stringForTitle= [NSString stringWithFormat:@"%@", [arrayOfYourPickerElements objectAtIndex:row]];// Fill the label text here 
labelFontName .text = stringForTitle; 
return labelFontName ; 
} 

家庭字體名的名字中選擇FontName後面:

yourTextView.font = [UIFont fontWithName:label size:17]; 
1
在這樣的假設提交我的回答

,定製自己否則,如果有任何疑問這裏問

-(void)pickerView:(UIPickerView *)pickerView didSelectRow: 
(NSInteger)row inComponent:(NSInteger)component{ 
    // here you can get index for selected Row 
    [yourTextView setText:[pickerArray objectAtIndex:row]]; 

    [yourTextView setFont:[UIFont fontWithName:@"Helvetica Neue" size:18.0f]]; 
yourTextView.textColor = [UIColor whiteColor]; 
} 

for picker tutorial

+0

我可以只更改字體系列 – Techiee

+0

@deepakkumar - 如果你知道該字體家族已經添加你的seif,肯定會工作 –

+0

我的意思是我不想改變字體大小,所以在做什麼那樣的話?@Anbu – Techiee

相關問題