ios如何在一个UIImageButton的里面加一些自定义的箭头

-(UIImage*) getOneImageButtonWithArrow{

//tmpView做附控件

UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 38.0f, 32.0f)];

tmpView.backgroundColor = [UIColor clearColor];

//bgImg作为背景

UIImage* bgImg = [UIImage imageNamed:@"background.png"];

UIImageView *bgImageView = [[UIImageView alloc] initWithImage:bgImg];

bgImageView.frame = tmpView.frame;

//加入tmpView

[tmpView addSubview:bgImageView];

[bgImageView release];

//里面的icon

UIImageView *tmpImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon.png"]];

tmpImageView.frame = CGRectMake(4.0f, 4.0f, 24.0f, 24.0f);

tmpImageView.backgroundColor = [UIColor clearColor];

tmpImageView.alpha = 1.0f;

[tmpView addSubview:tmpImageView];

//箭头

UIImage *arrowImage = [UIImage imageNamed:@"arrow.png"];

UIImageView *arrowImageView = [[UIImageView alloc] initWithImage:arrowImage];

arrowImageView.frame = CGRectMake(28.0f, 4.0f, 6.0f, 24.0f);

[tmpView addSubview:arrowImageView];

//获取上下文,得到这个UIImage

UIGraphicsBeginImageContextWithOptions(tmpView.bounds.size, NO, 0.0);

[tmpView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *tmpImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return tmpImage;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • //设置尺寸为屏幕尺寸的时候self.window = [[UIWindow alloc] initWithFra...
    LuckTime阅读 1,006评论 0 0
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥ios动画全貌。在这里你可以看...
    每天刷两次牙阅读 8,706评论 6 30
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,298评论 5 13
  • iphone开发笔记 退回输入键盘 - (BOOL) textFieldShouldReturn:(id)text...
    爱易寒曲易散阅读 696评论 0 1
  • 1、设置UILabel行间距 NSMutableAttributedString* attrString = [[...
    十年一品温如言1008阅读 2,073评论 0 3

友情链接更多精彩内容