0
나는 객관적인 C 언어로 새로운 기능을 제공하며 동일한 텍스트가있는 모든 ViewController에 나타나는 레이블을 만들려면 도움이 필요하지만이 텍스트는 계속 변경됩니다.내 모든보기에서 xcode로 레이블 만들기
감사합니다.
나는 객관적인 C 언어로 새로운 기능을 제공하며 동일한 텍스트가있는 모든 ViewController에 나타나는 레이블을 만들려면 도움이 필요하지만이 텍스트는 계속 변경됩니다.내 모든보기에서 xcode로 레이블 만들기
감사합니다.
당신이하는 .m 파일에서 .H 파일
//
// UILabel+withString.h
//
#import <Foundation/Foundation.h>
@interface UILabel (withString)
+ (UILabel *)labelWithString:(NSString *)string
font:(UIFont *)font
color:(UIColor *)color
container:(CGRect)container
origin:(CGPoint)origin;
@end
//
// UILabel+withString.m
//
#import "UILabel+withString.h"
@implementation UILabel (withString)
+ (UILabel *)labelWithString:(NSString *)string
font:(UIFont *)font
color:(UIColor *)color
container:(CGRect)container
origin:(CGPoint)origin {
CGSize size = [string sizeWithFont:font constrainedToSize:container.size
lineBreakMode:UILineBreakModeTailTruncation];
UILabel *label = [[[UILabel alloc]
initWithFrame:CGRectMake(origin.x, origin.y, container.size.width, size.height)] autorelease];
label.text = string;
label.font = font;
label.textColor = color;
label.textAlignment = UITextAlignmentLeft;
label.numberOfLines = 1;
label.lineBreakMode = UILineBreakModeTailTruncation;
label.backgroundColor = [UIColor clearColor];
return label;
}
@end
다음 뷰 컨트롤러에이
이 방법으로 호출 할 수 있습니다 내 레이블이 다른 ViewController에 나타 납니까? – user3376632
그냥이 파일 –
을 가져와야합니다. 어떻게 내 View Controller에서 호출 할 수 있습니까? – user3376632