IOS-1697 add a string extention to paint pep string to green paintPEPToPEPColour IOS-1697
authorAlejandro Gelos <agp@pep.security>
Fri, 09 Aug 2019 10:56:44 +0200
branchIOS-1697
changeset 9605be9da870ab63
parent 9604 f49b03fbc556
child 9606 a758b003cb1c
IOS-1697 add a string extention to paint pep string to green paintPEPToPEPColour
subModules/pEpIOSToolbox/pEpIOSToolbox/Foundation/String+pEp.swift
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/subModules/pEpIOSToolbox/pEpIOSToolbox/Foundation/String+pEp.swift	Fri Aug 09 10:56:44 2019 +0200
     1.3 @@ -0,0 +1,20 @@
     1.4 +//
     1.5 +//  String+pEp.swift
     1.6 +//  pEpIOSToolbox
     1.7 +//
     1.8 +//  Created by Alejandro Gelos on 09/08/2019.
     1.9 +//  Copyright © 2019 pEp Security SA. All rights reserved.
    1.10 +//
    1.11 +
    1.12 +import UIKit
    1.13 +
    1.14 +extension String {
    1.15 +    public func paintPEPToPEPColour() -> NSAttributedString {
    1.16 +        let range = (self as NSString).range(of: "p≡p")
    1.17 +        let paintedText = NSMutableAttributedString(string: self)
    1.18 +
    1.19 +        paintedText.addAttribute(
    1.20 +            NSAttributedString.Key.foregroundColor, value: UIColor.pEpGreen, range: range)
    1.21 +        return paintedText
    1.22 +    }
    1.23 +}