热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

把小图像放在UIImageView的顶部?-PutsmallimagesonthetopofUIImageView?

IvegotaUIImageViewinapagethatgetsitsimagefromtheInterfacebuilderandImtryingtopu

I've got a UIImageView in a page that gets its image from the Interface builder and I'm trying to put small icons on the top of it (it's a small map and I want to put icons on it). I know it's probably very simple but I tried to look it up in the documentation but it pretty much got me more confused.

我在一个页面中有一个UIImageView,它从Interface构建器获取它的图像,我试图在它的顶部放置小图标(这是一个小地图,我想在其上放置图标)。我知道它可能很简单,但我试着在文档中查找它,但它让我更加困惑。

3 个解决方案

#1


1  

Using Interface Builder, can't you just drag a UIImageView into an existing UIImageView? In effect, you end up with one UIImageView embedded within another.

使用Interface Builder,你不能只是将UIImageView拖入现有的UIImageView吗?实际上,您最终将一个UIImageView嵌入另一个UIImageView中。

You should also be able to easily set the hidden property of the "small map" UIImageView in code, depending on if that UIImageView is needed or not.

您还应该能够在代码中轻松设置“小地图”UIImageView的隐藏属性,具体取决于是否需要UIImageView。

Hope this helps. Good Luck.

希望这可以帮助。祝你好运。

  • Let It Be Known
  • 让它知道

#2


1  

you could compose your own UIView by adding both the large and small UIViewImage views.

你可以通过添加大型和小型UIViewImage视图来编写自己的UIView。

I have illustrated my approach below with the Pseudocode .

我已经用Pseudocode说明了我的方法。

-(id) initwithFrame:(CGRect) frame
{

  if(self = [super initWithFrame:frame])
  {

   iCOntainer= [[UIView alloc] initWithFrame:frame];

   [iContainer addSubViews:iLargerUIImageView];
   [iContainer addSubViews:iSmallUIImageView];

   [self.view addSubViews:iContainer];
  }
  return self;
}
-(void) layoutSubviews
{
    CGRect myRect = self.frame;
    iContainer.frame = myRect;
    //Give the location to iLargerUIImageView as per your requirement.
     iLargerUIImageView.frame = CGRectMake(...,...,...,...);
    //Give the location to iSmallUIImageViewas per your requirement.  
    iSmallUIImageView.frame = CGRectMake(...,...,...,...);

}

-(void) dealloc
{
  [iContainer release];
  [iLargerUIImageView release];
  [iSmallUIImageView release];
}

#3


0  

enter image description here

try this code:

试试这段代码:

UIImageView *backgroundImageView = (UIImageView *)[self viewWithTag:kBckGndImag];

UIImageView * backgroundImageView =(UIImageView *)[self viewWithTag:kBckGndImag];

if(!backgroundImageView){
    UIImage *imageName  =   [UIImage imageNamed:kpointsChartBig];

    backgroundImageView =   [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, imageName.size.width, imageName.size.height)]; 

    backgroundImageView.image=imageName;

    [backgroundImageView setTag:kBckGndImag];

    [pointImageView addSubview:backgroundImageView];

    [backgroundImageView release];
}

UIImageView *foregroundImageView = (UIImageView *)[self viewWithTag:kForGndImage];

if(!foregroundImageView){
    foregroundImageView =       [[UIImageView alloc] initWithImage:[UIImage imageNamed:kpointsColoredChartBig]];

    foregroundImageView.cOntentMode= UIViewContentModeLeft;

    foregroundImageView.clipsToBounds = YES;

    [pointImageView addSubview:foregroundImageView];

    [foregroundImageView release];
}

推荐阅读
  • 本文介绍了Python函数的定义与调用的方法,以及函数的作用,包括增强代码的可读性和重用性。文章详细解释了函数的定义与调用的语法和规则,以及函数的参数和返回值的用法。同时,还介绍了函数返回值的多种情况和多个值的返回方式。通过学习本文,读者可以更好地理解和使用Python函数,提高代码的可读性和重用性。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • Commit1ced2a7433ea8937a1b260ea65d708f32ca7c95eintroduceda+Clonetraitboundtom ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • Linux环境变量函数getenv、putenv、setenv和unsetenv详解
    本文详细解释了Linux中的环境变量函数getenv、putenv、setenv和unsetenv的用法和功能。通过使用这些函数,可以获取、设置和删除环境变量的值。同时给出了相应的函数原型、参数说明和返回值。通过示例代码演示了如何使用getenv函数获取环境变量的值,并打印出来。 ... [详细]
  • 在springmvc框架中,前台ajax调用方法,对图片批量下载,如何弹出提示保存位置选框?Controller方法 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
author-avatar
mobiledu2502898253
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有