This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended. To summarise this work: - [x] created a new **Xcode** project; - [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project; - [x] created the `Locations` app and also, its `Libraries` package; - [x] created the `Shared` package to share dependencies between the apps; - [x] added a `Makefile` file and implemented some **environment** and **help** commands. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#1
19 lines
1.1 KiB
Swift
19 lines
1.1 KiB
Swift
import Foundation
|
|
|
|
extension NSMutableAttributedString {
|
|
/// Applies a bold font to the first portion of the string that matches the given string
|
|
/// - Parameter matchingString: the string to search for and bold
|
|
/// - Parameter textStyle: The text style to use for the bolded string
|
|
/// - Parameter weight: The font weight to use for the bolded string
|
|
/// - Parameter traitCollection: The trait collection used for generating the font
|
|
public func applyBoldFont(to matchingString: String, textStyle: DynamicTextStyle, weight: UIFont.Weight = .semibold, matching traitCollection: UITraitCollection) {
|
|
// NSString and NSRange are used here for better compatability with NSAttributedString
|
|
let range = (string as NSString).range(of: matchingString, options: .caseInsensitive)
|
|
guard range.location != NSNotFound else {
|
|
return
|
|
}
|
|
let boldFont = UIFont.wmf_font(textStyle.with(weight: weight), compatibleWithTraitCollection: traitCollection)
|
|
addAttribute(.font, value: boldFont, range: range)
|
|
}
|
|
}
|