You can use the following method to write a function:
-(UIImage *) getOneImageButtonWithArrow {// tmpView is attached with the control UIView * tmpView = [[UIView alloc] initWithFrame: CGRectMake (0.0f, 0.0f, 38366f, 32.0f)]; tmpView. backgroundColor = [UIColor clearColor]; // bgImg as background UIImage * bgImg = [UIImage imageNamed: @ "background.png"]; UIImageView * bgImageView = [[UIImageView alloc] Background: bgImg]; bgImageView. frame = tmpView. frame; // Add tmpView [tmpView addSubview: bgImageView]; [bgImageView release]; // The icon UIImageView * tmpImageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "icon.png"]; tmpImageView. frame = CGRectMake (4.0f, 4.0f, 24366f, 24366f); tmpImageView. backgroundColor = [UIColor clearColor]; tmpImageView. alpha = 1.0f; [tmpView addSubview: tmpImageView]; // arrow UIImage * arrowImage = [UIImage imageNamed: @ "arrow.png"]; UIImageView * arrowImageView = [[UIImageView alloc] initWithImage: arrowImage]; arrowImageView. frame = CGRectMake (28366f, 4.0f, 6.0f, 24366f); [tmpView addSubview: arrowImageView]; // obtain the context and obtain the UIImage uigraphicsbeginimagecontextwitexceptions (tmpView. bounds. size, NO, 0.0); [tmpView. layer renderInContext: UIGraphicsGetCurrentContext ()]; UIImage * tmpImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext (); return tmpImage ;}