-1
這是迄今爲止我所做的,但是當我運行這個代碼時,所有邊界都形成了。我只需要獲取底部邊框。請幫忙。我問過的問題是UIImage View而不是UITextField。如何在ios(目標c)中爲UIImageView添加底部邊框?
CGFloat borderWidth = 1;
CALayer *bottomBorder = [CALayer layer];
[self.layer setBorderColor: [[UIColor blackColor] CGColor]];
[self.layer setBorderWidth: 2.0];
self.layer.frame = CGRectMake(0, self.frame.size.height - borderWidth,
self.frame.size.width, self.frame.size.height);
[self.layer addSublayer:bottomBorder];
您應該將邊框寬度和顏色設置爲圖層'bottomBorder'。 – clemens
改變'self.layer.frame = CGRectMake(0,self.frame.size.height - borderWidth, self.frame.size.width,self.frame.size.height);'into'self.layer.frame = CGRectMake(0,self.frame.size.height - borderWidth, self.frame.size.width,borderWidth);' –