반응형

UIabel 위에  UIImageView 를 올려서

이미지를 라벨 위에 노출되도록 하려고 하는데

 

iOS7 에서는 문제 없이 노출되는데

iOS8 에서는 UIImageView가 UILabel 밑으로 들어가 버리는 문제가 생겼습니다.

 

 

UILabel *trainLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0, posY, 85, 50)];
[cellView addSubview:trainLabel];
UIImage *noImage = [UIImage imageNamed:@"test.png"]; 
UIImageView *noImageView = [[UIImageView alloc] initWithImage:noImage]; 
noImageView.frame = CGRectMake(0, 0, 18.0, 18.0); 
[trainLabel addSubview:noImageView];

 

 

 

 iOS7 iOS8 






 

 

 

레이어 순서 문제로 보여

Subview들의 layer 순서를 조절할 수 있는 방법을 찾다 보니

다음의 함수를 찾을 수 있었습니다.

 

- insertSubview:(UIView *) aboveSubview:(UIView *)

Inserts a view above another view in the view hierarchy.

Declaration

SWIFT

func insertSubview(_ viewUIView,
      aboveSubview siblingSubviewUIView)

OBJECTIVE-C

- (void)insertSubview:(UIView *)view
         aboveSubview:(UIView *)siblingSubview

Parameters

view
The view to insert. It’s removed from its superview if it’s not a sibling ofsiblingSubview.
siblingSubview
The sibling view that will be behind the inserted view.

Discussion

This method establishes a strong reference to view and sets its next responder to the receiver, which is its new superview.

Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

 

참고: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instm/UIView/insertSubview:aboveSubview:

 

 

addSubview 대신 insertSubView: aboveSubview 를 이용하여

 

 

UIImage *noImage = [UIImage imageNamed:@"test.png"]; 
UIImageView *noImageView = [[UIImageView alloc] initWithImage:noImage]; 
noImageView.frame = CGRectMake(trainLabel.frame.origin.x, trainLabel.frame.origin.y, 18.0, 18.0);
[cellView insertSubview:noImageView aboveSubview:trainLabel];

 

 

위와 같이 수정하니

iOS8에서도 iOS7와 같이 UILabel 위에 UIImageView 를 놓을 수 있었습니다.

 

조금이나마 도움 되셨기를.... ^^

반응형
반응형

아이폰 앱 다운로드 링크

 

NSURL *appStoreURL = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id123456789"];[[UIApplication sharedApplication]openURL:appStoreURL];

 

참고

http://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store

반응형

+ Recent posts