코코아 터치에서 깜박이는 UILabel을 만들 수 있습니까? 아니면 코어 애니메이션과 함께 UIview가 필요합니까?UILabel 코코아 터치 깜박임
답변
재미를 위해, 나는이 서브 클래스 NSOperation을 쓰기로했다. 샘플보기 컨트롤러 코드
- (void)main {
SEL update = @selector(updateLabel);
[self setThreadPriority:0.0];
while (![self isCancelled]) {
if (label_ == nil)
break;
[NSThread sleepForTimeInterval:interval_];
[self performSelectorOnMainThread:update withObject:nil waitUntilDone:YES];
}
}
- (void)updateLabel {
BlinkingColors *currentColors = nil;
if (mode_)
currentColors = blinkColors_;
else
currentColors = normalColors_;
[label_ setTextColor:currentColors.textColor];
[label_ setBackgroundColor:currentColors.backgroundColor];
mode_ = !mode_;
}
BlinkingLabelOperation.m
에서발췌 :
- (void)viewDidLoad
{
[super viewDidLoad];
BlinkingColors *blinkColors = [[BlinkingColors alloc] initWithBackgroundColor:[UIColor whiteColor]
textColor:[UIColor redColor]];
BlinkingLabelOperation *blinkingOp = [[BlinkingLabelOperation alloc] initWithLabel:clickLabel freq:1.0 blinkColors:blinkColors];
// put the operation on a background thread
NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
[queue addOperation:blinkingOp];
[blinkColors release];
}
전체 목록은, 당신이 그것을 here을 찾을 수 있습니다. 의견을 남기고 당신의 생각을 알려주십시오.
안녕 검은 개구리, 당신의 답변과 당신의 코드에 대해 많이 감사합니다! 구현하기가 쉽고 멋지며 훌륭하게 작동하며 정확하게 찾고 있습니다. 두 가지 엄지 손가락 :-) – Winston
모든 UIView (UILabel 포함)는 켜기/끄기를 전환하여 "깜박"하게 할 수있는 hidden
속성을 가지고 있습니다.
Martin, 지적 해 주셔서 고맙습니다. 이 시점에서 UILabel은 나의 필요에 부합합니다. – Winston
UILabel은 UIView입니다. –
Martin의 조언을 듣고 NSTimer을보고 "깜박임"작업을 처리하십시오.
+ scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
- 1. 코코아 터치 : 메모리 관리
- 2. UIImageView의 코코아 터치 터치
- 3. 코코아 터치 :
- 4. 코코아 터치 : 레이아웃 작업 방법
- 5. 코코아 터치 - AVFoundation
- 6. 코코아 터치 - 모션 감지?
- 7. 코코아 터치 NSRegularExpression 패턴
- 8. 코코아 터치 - UIAnimation 질문
- 9. 코코아 터치 : 텍스트 장식
- 10. 코코아 터치 - 대화 상자?
- 11. 코코아 터치 - 버튼 누르기
- 12. 코코아 터치 UITableView 데이터
- 13. 코코아 터치 - 뷰
- 14. 코코아 터치 - 분할 컨트롤
- 15. 코코아 터치 - 메모리 관리
- 16. 코코아 터치 - 로딩 AVAudioPlayer
- 17. 코코아 터치 - 타이머
- 18. 코코아 터치 구현 파일?
- 19. 코코아 터치 데이터 지속성
- 20. 코코아 터치 - 타이머로 애니메이션하기
- 21. 코코아 터치 - 키보드 캡처
- 22. 코코아 터치 - UITextView 색상
- 23. 코코아 터치 - 프레임보기
- 24. 코코아 터치에서 UILabel 알파 레벨을 설정하십시오.
- 25. 코코아, QTMovieView에 NSWindow를 오버레이 할 때의 깜박임
- 26. 코코아 터치 : 동적으로 크기 조정보기
- 27. 코코아 터치 및 SQL 서버
- 28. 코코아 터치 - 카운트 다운 타이머
- 29. 코코아 터치 - tex 속성 변경?
- 30. Xcode 앱 누락 코코아 터치
** 경고! ** 깜박이는 사용자 인터페이스 요소는 특정 주파수에서 깜박이는 경우 간질 발작을 유발할 수 있습니다. 그러한 애니메이션을 구현할 때는주의하십시오. –