我必须实现一个带有矩形边框的按钮,它应该是这个
我正在使用以下代码执行此操作:
-(void)createDynamicView:(CGRect)frame{
UIButton *drugimgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
drugimgBtn.frame = frame;//CGRectMake(0, 0, 155, 130);
NSString *myurl = responseDrugInfo.ThumbImg; //by rajesh
NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:myurl]];
UIImage *tbImage = [[UIImage alloc] initWithData:imageData];
[drugimgBtn setBackgroundImage:tbImage forState:UIControlStateNormal];
[drugimgBtn addTarget:self action:@selector(imageButtonAction:) forControlEvents:UIControlEventTouchUpInside];
UIView * prescView = [[UIView alloc]init];
prescView.frame = frame;
prescView.layer.borderColor = [UIColor lightGrayColor].CGColor;
prescView.layer.borderWidth = 1.0f;
[prescView addSubview:drugimgBtn];
[scrollview addSubview:drugimgBtn];
//[prescView release];
[myurl release];
[tbImage release];
}
输出如下:
如何实现矩形边框,使其在第一张图像中显示为相同?