gpt4 book ai didi

iphone - UITextView subview UIImageView 隐藏输入的文本并滚动文本 iPhone?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:23:30 25 4
gpt4 key购买 nike

我的 iPhone 应用程序中有 UITextView。在 UITextView 中,我添加了 UIImageView 作为 subview 。当输入的文本达到最终高度时,文本将滚动到顶部。相反,UIImageView(带有图像)也滚动到顶部。我该如何处理停止图像滚动并允许文本滚动?这是我的代码供您引用,

    messageTextView = [[UITextView alloc] initWithFrame:CGRectMake(35, 5, 210, 30)];
messageTextView.delegate = self;
messageTextView.backgroundColor = [UIColor clearColor];
messageTextView.clipsToBounds = YES;
messageTextView.font = [UIFont fontWithName:@"Helvetica" size:14];
messageTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

textViewImageView = [[UIImageView alloc]initWithFrame: CGRectMake(0, 0, 210, 30)];
textViewImageView.image = [UIImage imageNamed: @"textbg.png"];
textViewImageView.contentMode = UIViewContentModeScaleToFill;
textViewImageView.contentStretch = CGRectMake(0.5, 0.5, 0, 0);
[messageTextView addSubview: textViewImageView];

[messageTextView sendSubviewToBack: textViewImageView];
[messageTextView addSubview:textViewLabel];

谁能帮我解决这个问题?提前致谢。期待你的回复。

enter image description here

最佳答案

您是否考虑过将 imageView 置于 textView 之后?或者有什么理由禁止这样的布局?

类似的东西:

UITextView *messageTextView = [[UITextView alloc] initWithFrame:CGRectMake(35, 5, 210, 30)];
// ...
messageTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:messageTextView];

UIImageView *textViewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(35, 5, 210, 30)];
// ...
textViewImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:textViewImageView];

[self.view sendSubviewToBack:textViewImageView];

关于iphone - UITextView subview UIImageView 隐藏输入的文本并滚动文本 iPhone?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12584983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com