Ios 标签有模糊的边界

Ios 标签有模糊的边界,ios,uilabel,border,calayer,Ios,Uilabel,Border,Calayer,我认为默认值是边框宽度为0.0。所以我很惊讶在我的学校周围能看到寄宿生。我甚至尝试使用CALayer将边框设置为0.0并将其设置为白色,但仍然可以看到模糊的轮廓。这是我的密码 -(UIView *)calendarDay:(int)d date:(NSDate *)date width:(float)w height:(float)h { //d is the day number in the month of the 28/293 calendar. It should display in

我认为默认值是边框宽度为0.0。所以我很惊讶在我的学校周围能看到寄宿生。我甚至尝试使用CALayer将边框设置为0.0并将其设置为白色,但仍然可以看到模糊的轮廓。这是我的密码

-(UIView *)calendarDay:(int)d date:(NSDate *)date width:(float)w height:(float)h
{
//d is the day number in the month of the 28/293 calendar. It should display in bold in the upper, left.
//date is the date of that day. It should display in the upper, right.
//w is the width of the UIView in which to insert the labels.
//h is the height of the UIView in which to insert the labels.
//First create an outer view with a red background color.
UIView *frameView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
[frameView setBackgroundColor:[UIColor redColor]];
//Next decrease the width and height slightly to make a smaller view that fits inside the larger one.
w = w*0.98;
h = h*0.98;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM-dd "];
UILabel *dayNumber = [[UILabel alloc] init];
dayNumber.text = [NSString stringWithFormat:@"%2d",d];
dayNumber.font = [UIFont boldSystemFontOfSize:16];
dayNumber.frame = CGRectMake(0,0,w/2,h/5);
dayNumber.backgroundColor = [UIColor whiteColor];
UILabel *gregDate = [[UILabel alloc] init];
gregDate.text = [dateFormat stringFromDate:date];
gregDate.textAlignment = NSTextAlignmentRight;
gregDate.frame = CGRectMake(w/2,0,w/2,h/5);
gregDate.backgroundColor = [UIColor whiteColor];
以下三条线是试图使边界消失。这没什么区别

CALayer *gregDateLayer = [gregDate layer];
[gregDateLayer setBorderColor:[[UIColor whiteColor] CGColor]];
[gregDateLayer setBorderWidth:0.0];

[gregDate setTextColor:[UIColor blackColor]];
CGRect dayRect = CGRectMake(0, 0, w, h);
UIView *dayToReturn = [[UIView alloc] initWithFrame:dayRect];
[dayToReturn setBackgroundColor:[UIColor whiteColor]];
dayNumber.center = CGPointMake(w/4 ,h/4);
gregDate.center = CGPointMake(w*3/4,h/4);
[dayToReturn addSubview:dayNumber];
[dayToReturn addSubview:gregDate];
[frameView addSubview:dayToReturn];
dayToReturn.center = frameView.center;
return frameView;
}

我认为你所想的边界实际上是UILabel的背景色


将UILabels的背景色设置为
[UIColor clearColor]

,这样做了。我想知道为什么白色不起作用。白色上的白色是白色,就像白色上的透明是白色一样。也许不是。也许有一些阴影渲染正在进行,但在clear中不会发生?