탭 모음을 다시 만들고 싶지만이 문제가 발생했습니다. 아래 이미지에서 볼 수 있듯이, 현재 선택된 (오른쪽 이미지) 탭 바 항목은 UITabBar의 것보다 훨씬 선명하거나 선명합니다. 왼쪽의 아이콘 주위에 작은 1 포인트 경계가 있음을 알 수 있습니다.이 경계선은 내 눈에 띄는 아이콘 안에있는 그라디언트뿐입니다. 이미 Core Graphics 및 Core Images Filters를 가능한 접근 방식으로 생각했지만 그 효과를 얻지 못하는 것 같습니다. 나는 내가 원하는 부분의 일부인 더 오래된 thread을 발견했다. 그러나 대답은 나를 위해 작동하지 않는 것처럼 보이고 이미지의 픽셀을 통해 수동 루프가 필요하다. (내가 원하는지 모르겠다.) 누군가 나를 도울 수 있습니까? 선택한 UITabBarItem 테두리 다시 만들기
이
은 내가 코어 그래픽으로 시작하고 어떤 때문에 보는 경우에 BTW, 당신은 몇 가지 실수를 수정하기 환영합니다, 제가 현재 사용하고 코드입니다 :
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextSaveGState(context);
{
/* Adjust for different coordinate systems from UIKit and Core Graphics and center the image */
CGContextTranslateCTM(context, self.bounds.size.width/2.0 - self.image.size.width/2.0, self.bounds.size.height - self.bounds.size.height/2.0 + self.image.size.height/2.0);
CGContextScaleCTM(context, 1.0f, -1.0f);
CGRect rect = CGRectMake(0, 0, self.image.size.width, self.image.size.height);
/* Add a drop shadow */
UIColor *dropShadowColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f];
CGContextSetShadowWithColor(context, CGSizeMake(0, 1), 5, dropShadowColor.CGColor);
/* Draw the original image */
CGContextDrawImage(context, rect, self.image.CGImage);
/* Clip to the original image, so that we only draw the shadows on the
inside of the image but nothing outside. */
CGContextClipToMask(context, rect, self.image.CGImage);
if(self.isSelected){
/* draw background image */
CGImageRef background = [UIImage imageNamed:@"UITabBarBlueGradient"].CGImage;
CGContextDrawImage(context, rect, background);
}
else{
/* draw background color to unselected items */
CGColorRef backgroundColor = [UIColor colorWithRed:95/255.0 green:95/255.0 blue:95/255.0 alpha:1].CGColor;
CGContextSetFillColorWithColor(context, backgroundColor);
CGContextFillRect(context, rect);
/* location of the gradient's colors */
CGFloat locations[] = { 0.0, 1.0 };
NSArray *colors = [NSArray arrayWithObjects:(id)[UIColor colorWithRed:1 green:1 blue:1 alpha:0].CGColor, (id)[UIColor colorWithRed:1 green:1 blue:1 alpha:0.6].CGColor, nil];
/* create the gradient with colors and locations */
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace,(__bridge CFArrayRef) colors, locations);
{
/* start and end points of the gradient */
CGPoint startPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect));
CGPoint endPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect));
/* draw gradient */
CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
}
CGGradientRelease(gradient);
}
}
CGContextRestoreGState(context);
CGColorSpaceRelease(colorSpace);
}