2014-03-04 3 views
0

안녕하세요 임 프로그래밍이프로그래밍

`

- (UILabel *)titleLabel { 
if (!_titleLabel) { 
    _titleLabel = [[[UILabel alloc] init] initWithFrame:CGRectMake(0.0, _photoView.frame.size.height, _photoView.frame.size.width, 100.0)]; 
    // _titleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5]; 
    _titleLabel.backgroundColor =[UIColor clearColor]; 
    _titleLabel.textColor = [UIColor whiteColor]; 
    _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14]; 
    _titleLabel.textAlignment = NSTextAlignmentRight; 

    [self addSubview:_titleLabel]; 
} 
return _titleLabel; 

} 같은 UILabel을 만드는 UILabel의의 Y, 중간막을 변경할 수 없습니다`

_photoView

내가 이미 만든 UIImageView입니다. UILabel Y 값보기를 변경하고 싶습니다. 그러나 문제는이 두 번째 매개 변수 레이블을 변경하면 y 위치가 변경되지 않는다는 것입니다. 어느 누구나이 이유를 알 수 있습니다.

그리고 이것이 내가이 라인에서 이미지 뷰

`

- (UIImageView *)photoView { 
    if (!_photoView) { 
    _photoView = [[UIImageView alloc] init]; 
    _photoView.contentMode = UIViewContentModeScaleAspectFill; 
    _photoView.clipsToBounds = YES; 
    _photoView.layer.cornerRadius = 5; 
    _photoView.clipsToBounds = YES; 

    [self addSubview:_photoView]; 
} 
return _photoView; 
}` 

감사

+0

인터페이스 빌더에서 자동 레이아웃을 사용 중지했는지 확인하십시오. 그것에 내 대답은 : http://stackoverflow.com/questions/21042733/programmatically-moving-a-uilabel-in-a-xib-file/21042987#21042987 – nzs

+0

나는 당신이 변화하는 부분을 보지 않을거야. 당신이 언급 한 'Y'값 ... – holex

+0

이 _titleLabel = [[[UILabel alloc] init] initWithFrame의 두 번째 매개 변수를 변경하려고 시도했습니다. CGRectMake (0.0, _photoView.frame.size.height, _photoView.frame.size.width , 100.0)]; – user2889249

답변

0

을 생성하는 방법이다가, 당신은 두 가지 유형이

[[[UILabel alloc] init] initWithFrame:CGRectMake(0.0, _photoView.frame.size.height, _photoView.frame.size.width, 100.0)] 

변경이 라인에 init을 사용했다

[[UILabel alloc] initWithFrame:CGRectMake(0.0, _photoView.frame.size.height, _photoView.frame.size.width, 100.0)]