다음 코드가 있습니다.UIColor colorWithPatternImage는 이미지 색상을 변경합니다.
//Create a view to place repeated arrow in.
UIView *rootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
//Add Repeated Arrows to the top of the view using a color pattern.
UIImage *arrowImage = [UIImage imageNamed:@"arrow-down"];
UIColor *repeatedArrowColor = [UIColor colorWithPatternImage:arrowImage];
CGRect repeatedArrowFrame = CGRectMake(0, 0, 320.0, [arrowImage size].height);
UIView *repeatedArrowView = [[UIView alloc] initWithFrame:repeatedArrowFrame];
[repeatedArrowView setBackgroundColor:repeatedArrowColor];
[rootView addSubview:repeatedArrowView];
사용중인 이미지는 화살표가 # 323232 인 png입니다. .app 파일을 마우스 오른쪽 버튼으로 클릭하고 패키지 내용 표시를 선택하여 확인했습니다. 패턴 IOS는 시뮬레이터 화면에 나타날 때
그러나 화살표의 색은 # # 262,626 또는 252,525이다.
사람이 문제로 실행 했습니까? 그렇다면 어떻게 수정 했습니까? 해결 했습니까?
답장을 보내 주셔서 감사합니다. 전에는이 문제에 결코 빠지지 않았습니다. 아마도 PNG를 사용하기 전에 Apple의 압축 PNG 옵션을 사용하거나 ImageOptim을 적용했기 때문일 수 있습니다. – Tobias
호기심 - 원하는 값을 어떻게 얻었습니까? –
글쎄, 당신이 대답하기 전에 나는 png 사용을 중단했다. 대신 CoreGraphics로 단일 화살표를 그 다음 패턴의 기본으로 사용합니다. – Tobias