установка прямоугольной границы для UIButton - PullRequest
1 голос
/ 29 августа 2011

Я должен реализовать кнопку с прямоугольной рамкой, и она должна быть такой: enter image description here

и я использую следующий код для этого:

-(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];


}

Вывод следующий: enter image description here

Как реализовать прямоугольную рамку, чтобы она могла выглядеть так же, как на первом изображении?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...