swift 2.0 convert UIFontDescriptorSymbolicTraits to CTFontSymbolicTraits

269 Views Asked by At

How I can convert a UIFontDescriptorSymbolicTraits to CTFontSymbolicTraits ?

1

There are 1 best solutions below

2
matt On BEST ANSWER

Look at how they are defined. Here is CTFontSymbolicTraits:

enum {
kCTFontItalicTrait = (1 << 0),
kCTFontBoldTrait = (1 << 1),
kCTFontExpandedTrait = (1 << 5),
kCTFontCondensedTrait = (1 << 6),
// ...
};
typedef uint32_t CTFontSymbolicTraits;

Here is UIFontDescriptorSymbolicTraits:

typedef enum : uint32_t {
   UIFontDescriptorTraitItalic = 1u << 0,
   UIFontDescriptorTraitBold = 1u << 1,
   UIFontDescriptorTraitExpanded = 1u << 5,
   UIFontDescriptorTraitCondensed = 1u << 6,
   // ...
} UIFontDescriptorSymbolicTraits;

Notice anything? As far as the traits that matter to you are concerned, they are in fact identical. There is nothing to convert.