Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSAttributedString*)attributedName {
- NSMutableAttributedString* name = [[NSMutableAttributedString alloc] initWithString:self.name];
- [name setAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]} range:[self.name rangeOfString:self.lastname]];
- return name;
- }
- UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
- uint32_t existingTraitsWithNewTrait = UIFontDescriptorTraitBold;
- fontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:existingTraitsWithNewTrait];
- UIFont *updatedFont = [UIFont fontWithDescriptor:fontDescriptor size:0.0];
- NSDictionary *attribs = @{NSFontAttributeName : updatedFont};
- [mutableAttrString setAttributes:attribs range:result.range];
- public extension UILabel {
- /// Makes the text bold.
- public func makeBold() {
- //get the UILabel's fontDescriptor
- let desc = self.font.fontDescriptor().fontDescriptorWithSymbolicTraits(.TraitBold)
- //Setting size to '0.0' will preserve the textSize
- self.font = UIFont(descriptor: desc, size: 0.0)
- }
- }
- let s = "(client.givenName) (client.surname)" as NSString
- let myAttribute = [ NSFontAttributeName: UIFont.preferredFontForTextStyle(UIFontTextStyleTitle1) ]
- let myString = NSMutableAttributedString(string: "(s)", attributes: myAttribute )
- let myRange = s.rangeOfString(client.surname)
- let desc = UIFont.preferredFontForTextStyle(UIFontTextStyleTitle1).fontDescriptor().fontDescriptorWithSymbolicTraits(.TraitBold)
- let new = UIFont(descriptor: desc, size: 0.0)
- myString.addAttribute(NSFontAttributeName, value: new, range: myRange)
- nameLabel.attributedText = myString
- [name setAttributes:@{NSStrokeWidthAttributeName : @-3.0} range:NSRangeFromString(name.string)];
- name.setAttributes([.strokeWidth: NSNumber(value: -3.0)], range: NSRangeFromString(name.string))
Add Comment
Please, Sign In to add comment