[iOS] UILabel random Textcolor
UILabel의 텍스트 컬러를 랜덤으로 만들어 볼까요.
개발도중 여러개의 데이터를 받아와 UILabel로 뿌려줘야 하는데 검은색으로 하기에는 너무 심심해서 구글링을 한 결과 역시나 소스가 있네요.
CGFloat redLevel = rand() / (float) RAND_MAX;
CGFloat greenLevel = rand() / (float) RAND_MAX;
CGFloat blueLevel = rand() / (float) RAND_MAX;
[label setTextColor:[UIColor colorWithRed: redLevel
green: greenLevel
blue: blueLevel
alpha: 1.0]];
적용해보았는데 너무 이쁩니다.
반응형
그리드형
'IT > iOS' 카테고리의 다른 글
xcode7 bitcode 오류 (0) | 2015.09.18 |
---|---|
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. (0) | 2015.09.18 |
[iOS] uiscrollview 스크롤시 맨위로 버튼 처리 (0) | 2015.08.13 |
x-apple-amd-action_message (13) | 2015.08.03 |
[iOS] UIView 부분적으로 라운드 적용하기 (2) | 2015.05.19 |
[iOS] 앱평가 하기, 리뷰 남기기는 iRate로 (0) | 2015.03.30 |
iOS8 버그 unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow (0) | 2014.11.06 |
iOS8 푸쉬 등록 에러메세지 (registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later) (0) | 2014.10.02 |