둥근 모서리에 그림자와 작은 테두리가있는 사각형 인 사용자 정의 UIView가 있습니다. 그것은 단지 둥근 모서리 사각형과 경계하지만 그림자를 렌더링CGContextSetShadowWithColor가 장치에 표시되지 않습니다.
- (void) drawRect:(CGRect)rect {
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//// Shadow Declarations
CGColorRef shadow = [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.3].CGColor;
CGSize shadowOffset = CGSizeMake(0, 1);
CGFloat shadowBlurRadius = 2;
//// Abstracted Graphic Attributes
CGRect roundedRectangleFrame = CGRectMake(2, 0, rect.size.width - 4, rect.size.height - 2);
//// Rounded Rectangle Drawing
UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: roundedRectangleFrame cornerRadius: 2];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow);
[[UIColor whiteColor] setFill];
[roundedRectanglePath fill];
CGContextRestoreGState(context);
[[UIColor colorWithRed:200.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:0.3] setStroke];
roundedRectanglePath.lineWidth = 0.5;
[roundedRectanglePath stroke];
}
내 문제는 시뮬레이터에 모든 것이 완벽하게 렌더링되는 것입니다하지만이 장치에서 코드를 실행하면 (나는 아이팟 터치 4 세대를 사용). 어떤 아이디어?
더 큰 그림자로 시도 했습니까? – Larme
네, 장치에 얼마나 큰지 확인해 보았습니다. 빨강 색을 사용해 보았습니다. – FrankWest
경계선을 벗어 났습니까? 나는. 그림자가 잘린거야? –