开发者

setting rectangular border for UIButton

I have to implement a button with rectangular border and it should be like this

setting rectangular border for UIButton

and I am using the following code to do that:

-(void)createDynamicView:(CGRect)frame{

UIButton *drugimgBtn        = [UIButton buttonWithType:UIButtonTypeCustom];
drugimgBt开发者_JS百科n.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];


}

The output is as follow:

setting rectangular border for UIButton

How do I implement a rectangular border so it can appeared like the same in the first image?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜