Programing

iPhone 시스템 글꼴

lottogame 2020. 8. 24. 20:50
반응형

iPhone 시스템 글꼴


iPhone의 기본 시스템 글꼴 이름은 무엇입니까?

사용자 정의를 위해 이것을 검색하고 싶습니다 UIView.


글꼴 순수 주의자들의 기쁨을 위해 iPhone 시스템 인터페이스는 Helvetica 또는 그 변형을 사용합니다.

원래 iPhone, iPhone 3G 및 iPhone 3GS 시스템 인터페이스는 Helvetica를 사용합니다. 항상 뛰어난 DaringFireball이 처음 언급했듯이 iPhone 4는 "Helvetica Neue"라는 미묘하게 수정 된 글꼴을 사용합니다. DaringFireball은 또한이 변경 사항이 iOS 4 운영 체제가 아닌 iPhone 4 디스플레이와 관련이 있으며 iOS 4를 실행하는 이전 iPhone 모델은 여전히 ​​시스템 글꼴로 Helvetica를 사용한다고 언급합니다.

iPhone 이전에 출시 된 iPod 모델은 Chicago, Espy Sans 또는 Myriad를 사용하고 iPhone 출시 후 Helvetica를 사용합니다.

에서 http://www.everyipod.com/iphone-faq/iphone-who-designed-iphone-font-used-iphone-ringtones.html

들어 iOS9 이 변경되었습니다 샌 프란 시스 코 . 자세한 내용은 http://developer.apple.com/fonts참조 하십시오 .


프로그래밍 방식의 사용자 지정을 수행하는 경우 시스템 글꼴을 하드 코딩하지 마십시오. UIFont systemFontOfSize:, UIFont boldSystemFontOfSize:UIFont italicSystemFontOfSize( Apple 문서 )를 사용하십시오 .

이것은 시스템 글꼴을 Helvetica Neue로 변경 한 iOS 7 이후로 특히 관련이 있습니다.

이것은 시스템 글꼴 을 샌프란시스코로 다시 변경 한 iOS 9 이후로 특히 관련성 높아 졌습니다.


afaik iPhone은 기본적으로 " Helvetica "를 사용합니다. <iOS 10


빠른

특정 글꼴

Swift에서 특정 글꼴을 설정하는 방법은 다음과 같습니다.

let myFont = UIFont(name: "Helvetica", size: 17)

이름을 모르면 다음과 같이 사용 가능한 글꼴 이름 목록을 얻을 수 있습니다.

print(UIFont.familyNames())

또는 다음과 같은 더 자세한 목록 :

for familyName in UIFont.familyNames() {
    print(UIFont.fontNamesForFamilyName(familyName))
}

그러나 시스템 글꼴은 iOS 버전마다 변경됩니다. 따라서 시스템 글꼴을 동적으로 얻는 것이 좋습니다.

시스템 글꼴

let myFont = UIFont.systemFontOfSize(17)

그러나 우리는 크기가 하드 코딩되어 있습니다. 사용자의 눈이 나빠서 글꼴을 더 크게 만들고 싶다면 어떨까요? 물론 앱에서 사용자가 글꼴 크기를 변경하도록 설정할 수 있지만 사용자가 휴대 전화의 모든 앱에 대해 개별적으로이 작업을 수행해야한다면 성 가실 것입니다. 일반 설정에서 한 번만 변경하는 것이 더 쉬울 것입니다.

동적 글꼴

let myFont = UIFont.preferredFont(forTextStyle: .body)

아, 이제 우리가 작업중인 텍스트 스타일에 대해 사용자가 선택한 크기의 시스템 글꼴 이 있습니다. 이것이 권장되는 글꼴 설정 방법입니다. 이에 대한 자세한 내용은 동적 유형 지원을 참조하십시오 .

관련


당신은 항상 사용할 수 있습니다

UIFont *systemFont = [UIFont systemFontOfSize:12];
NSLog(@"what is it? %@ %@", systemFont.familyName, systemFont.fontName);

정답은:

최대 iOS 6

 Helvetica Helvetica

IOS 7

.Helvetica Neue Interface .HelveticaNeueInterface-M3

하지만 그냥 사용할 수 있습니다 Helvetica Neue


기본 시스템 글꼴 이름을 가져 오는 API가 있는지 잘 모르겠습니다. 그래서 나는 다음과 같은 이름을 얻습니다.

    //get system default font
    UILabel *label = [[UILabel alloc] init];        
    fontname = label.font.fontName;
    [label release];

어리석은 것처럼 보이지만 작동합니다.


다음은 iOS 7 지원을위한 업데이트입니다 . 그것은 가지고 Dynamic Font Size지금.

"동적 유형"을 지원하는 모든 앱의 경우 사용자는 "설정"의 "일반"섹션을 방문하고 "글꼴 크기"를 선택하기 만하면 시스템 전체에서 작동하는 iOS 7의 글꼴 크기를 선택할 수 있습니다.

UIFont *dynamicFont  = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

And constants list, detailed explanation is here

NSString *const UIFontTextStyleHeadline;
NSString *const UIFontTextStyleSubheadline;
NSString *const UIFontTextStyleBody;
NSString *const UIFontTextStyleFootnote;
NSString *const UIFontTextStyleCaption1;
NSString *const UIFontTextStyleCaption2;

Category UIFontSystemFonts for UIFont (UIInterface.h) provides several convenient predefined sizes.

@interface UIFont (UIFontSystemFonts)
 + (CGFloat)labelFontSize;
 + (CGFloat)buttonFontSize;
 + (CGFloat)smallSystemFontSize;
 + (CGFloat)systemFontSize;
@end 

I use it for chat messages (labels) and it work well when I need to get size of text blocks.

 [UIFont systemFontOfSize:[UIFont labelFontSize]];

Happy coding!


UIFont *systemFont = [UIFont systemFontOfSize:[UIFont systemFontSize]];

This will give you the system font with the default system font size applied for the label texts by default.


Swift

You should always use the system defaults and not hard coding the font name because the default font could be changed by Apple at any time.

There are a couple of system default fonts(normal, bold, italic) with different sizes(label, button, others):

let font = UIFont.systemFont(ofSize: UIFont.systemFontSize)
let font2 = UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)
let font3 = UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)

beaware that the default font size depends on the target view (label, button, others)

Examples:

let labelFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
let buttonFont = UIFont.systemFont(ofSize: UIFont.buttonFontSize)
let textFieldFont = UIFont.systemFont(ofSize: UIFont.systemFontSize)

  1. download required .ttf file

  2. add the .ttf file under copy bundle resource, double check whether the ttf file is added under resource

  3. In info.pllist add the ttf file name as it is.

  4. now open the font book add the .ttf file in the font book, select information icon there you find the postscript name.

  5. now give the postscript name in the place of font name


The default font for iOS is San Francisco . You can refer the link for further details

참고URL : https://stackoverflow.com/questions/3838336/iphone-system-font

반응형