【问题标题】:Insert UImageVIew into UITextField在 UITextField 中插入图像视图
【发布时间】:2009-12-29 14:38:27
【问题描述】:

如何将图像添加到文本字段?我在一些应用程序中看到它,但无法绕过它。同样基于光标的位置,imageView 将被初始化(将图像添加到下一行)。谢谢。

【问题讨论】:

    标签: cocoa xcode3.2


    【解决方案1】:

    如果您的意思是在文本字段的文本框中插入图像,我认为这是不可能的。你想达到什么目的?可能有更合适的方法。

    【讨论】:

      【解决方案2】:

      是的,我们可以使用以下代码将 imageview 插入到 textfield 中。

       UIImageView *myView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"text_line.png"]];
       myView.center = CGPointMake(5, 27);                     
       [letterField insertSubview:myView atIndex:0];// mgViewTitleBackGround is image
       [myView release];
      

      浏览这段代码。

      【讨论】:

      • 不会根据光标的位置定位视图,所以我认为这并不能真正回答问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 2021-11-06
      • 1970-01-01
      相关资源
      最近更新 更多