我正在嘗試製作書籍應用程序。我用可顯示長字符串的文字填充。基本上,我試圖使用UI標籤,但它只顯示一行,其餘文本被剪切。如何讓長文本的頁面基於手機屏幕自動打包
任何想法我應該用什麼樣的UI來製作一本書?謝謝。
我正在嘗試製作書籍應用程序。我用可顯示長字符串的文字填充。基本上,我試圖使用UI標籤,但它只顯示一行,其餘文本被剪切。如何讓長文本的頁面基於手機屏幕自動打包
任何想法我應該用什麼樣的UI來製作一本書?謝謝。
你必須使用的UITextView用於此目的的檢查
UITextView *aboutStable = [[UITextView alloc] init];
[aboutStable setFont:[UIFont fontWithName:@"Helvetica" size:12]];
[aboutStable setText:@"Write your long text here............iphonemaclover is great"];
[aboutStable setTextColor:[UIColor grayColor]];
[aboutStable setBackgroundColor:[UIColor clearColor]];
[aboutStable setTextAlignment:UITextAlignmentCenter];
[aboutStable setFrame:CGRectMake(0, 302, 320, 79)];
[self addSubview:aboutStable];
,並使其不可編輯這樣設置
[aboutStable setUserInteractionEnabled:NO]
應該這樣做
,如果你需要滾動:
aboutStable.editable = NO;
或者如果你的文字是sti LL更多,那麼你可以設置滾動型的太...
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 195, 280, 10)];
textView.text = @"your long text here";
textView.font = [UIFont fontWithName:@"Hevlatica" size:14];
[self.scrollView addSubview:textView];//add scrollview using Xib and set property of it.
CGRect descriptionFrame = textView.frame;
descriptionFrame.size.height = textView.contentSize.height;
textView.frame = descriptionFrame;
,或者你可以在這個sample code
編輯不同的Retina顯示屏
CGRect screenRect = [[UIScreen mainScreen] bounds];
if (screenRect.size.height == 568.0f)
{
//condition for iphone 5 screen
}
else
{
//condition for retina display 3.5
}
將UILabel的numberOfLines設置爲0,讓它根據需要使用盡可能多的行。
確定這裏查看更詳細的,我發現[aboutStable setFrame:CGRectMake(0,0,320,400)];是textview的完美矩形。但我只是意識到一件事,如果用戶使用視網膜顯示或另一個具有不同大小的手機。在這種情況下如何處理多種尺寸的iphone。 –
檢查編輯部分在上面的答案不要忘記upvote,如果它可以幫助你! – iphonemaclover