私はuitextviewに画像を入れなければならないアプリを作っています。私が直面している問題は、2 つの画像の真ん中にテキストを書き込むときに、それに応じて画像を移動するにはどうすればよいかということです。サンプル コードを歓迎します。
質問する
177 次
1 に答える
0
ここでは、1つの画像のサンプルコードを提供しています。
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
{
if ( [text isEqualToString:@"\n"] ) {
}
else
{
NSString *yourstring = [[NSString alloc]init];
yourstring = textView.text;
CGSize s = [yourstring sizeWithFont:[UIFont systemFontOfSize:15] //define your textview font size
constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT) // - 40 For cell padding
lineBreakMode:UILineBreakModeWordWrap];
CGRect frame = CGRectMake(0.0f, s.height+10, 320.0f, 20);//use YourImageView. height and width
YourImageView.frame=frame;
}
return YES;
}
うまくいけば、これはあなたを助けるでしょう..
于 2012-05-09T11:39:19.980 に答える