UILabel 또는 다른 컨트롤 (UIButton, UITextField 등)의 범주 클래스를 만듭니다.
UILabel + DynamicFontSize.시간
#import <UIKit/UIKit.h>
@interface UILabel (DynamicFontSize)
@property (nonatomic) IBInspectable BOOL adjustFontSize;
@end
UILabel의 + DynamicFontSize.m
#import "UILabel+DynamicFontSize.h"
@implementation UILabel (DynamicFontSize)
@dynamic adjustFontSize;
-(void)setAdjustFontSize:(BOOL)adjustFontSize{
if (adjustFontSize)
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.font = [self.font fontWithSize:self.font.pointSize*(screenBounds.size.width/320)]; // 320 for iPhone 5(320x568) storyboard design
// if you design with iphone 6(375x667) in storyboard, use 375 instead of 320 and iphone 6 plus(414x736), use 414
}
}
@end
사용
는 레이블을 선택하고 속성 이름이
ON
에 글꼴 크기 변경 값을 조정 발견
프로젝트에서 큰 글꼴을 사용하고 자동 축척으로 줄 수를 설정하면 글꼴 크기를 통해 글꼴 크기를 줄일 수 있습니다 – Tj3n
보관할 크기 클래스를 사용할 수 있습니다 –
@SagarBhut 저를 도울 수 있습니까? , 크기 클래스로 달성하는 방법. – srinadh