Swift 链式封装进阶/终结篇:工具批量属性转链式方法

2021-04-22  本文已影响0人  SoaringHeart

链式编程好处不必再次强调,大家都知道,效果如下:

ScreenShots7.jpeg

CodeHelper.dmg

UIButton

public extension UIButton {

    // default is UIEdgeInsetsZero. On tvOS 10 or later, default is nonzero except for custom buttons.
    func contentEdgeInsets(_ contentEdgeInsets: UIEdgeInsets) -> Self {
        self.contentEdgeInsets = contentEdgeInsets
        return self
    }

    // default is UIEdgeInsetsZero
    func titleEdgeInsets(_ titleEdgeInsets: UIEdgeInsets) -> Self {
        self.titleEdgeInsets = titleEdgeInsets
        return self
    }

    // default is NO. if YES, shadow reverses to shift between engrave and emboss appearance
    func reversesTitleShadowWhenHighlighted(_ reversesTitleShadowWhenHighlighted: Bool) -> Self {
        self.reversesTitleShadowWhenHighlighted = reversesTitleShadowWhenHighlighted
        return self
    }

    // default is UIEdgeInsetsZero
    func imageEdgeInsets(_ imageEdgeInsets: UIEdgeInsets) -> Self {
        self.imageEdgeInsets = imageEdgeInsets
        return self
    }

    // default is YES. if YES, image is drawn darker when highlighted(pressed)
    func adjustsImageWhenHighlighted(_ adjustsImageWhenHighlighted: Bool) -> Self {
        self.adjustsImageWhenHighlighted = adjustsImageWhenHighlighted
        return self
    }

    // default is YES. if YES, image is drawn lighter when disabled
    func adjustsImageWhenDisabled(_ adjustsImageWhenDisabled: Bool) -> Self {
        self.adjustsImageWhenDisabled = adjustsImageWhenDisabled
        return self
    }

    // default is NO. if YES, show a simple feedback (currently a glow) while highlighted
    func showsTouchWhenHighlighted(_ showsTouchWhenHighlighted: Bool) -> Self {
        self.showsTouchWhenHighlighted = showsTouchWhenHighlighted
        return self
    }

    // The tintColor is inherited through the superview hierarchy. See UIView for more information.
    @available(iOS 5.0, *)
    func tintColor(_ tintColor: UIColor!) -> Self {
        self.tintColor = tintColor
        return self
    }

    // default is UIButtonRoleNormal. 
    @available(iOS 14.0, *)
    func role(_ role: UIButton.Role) -> Self {
        self.role = role
        return self
    }

    @available(iOS 13.4, *)
    func isPointerInteractionEnabled(_ isPointerInteractionEnabled: Bool) -> Self {
        self.isPointerInteractionEnabled = isPointerInteractionEnabled
        return self
    }
    
    @available(iOS 14.0, *)
    func menu(_ menu: UIMenu?) -> Self {
        self.menu = menu
        return self
    }
        
    func setTitleChain(_ title: String?, for state: UIControl.State) -> Self {
        setTitle(title, for: state)
        return self
    }

    func setTitleColorChain(_ color: UIColor?, for state: UIControl.State) -> Self {
        setTitleColor(color, for: state)
        return self
    }
    func setTitleShadowColorChain(_ color: UIColor?, for state: UIControl.State) -> Self {
        setTitleShadowColor(color, for: state)
        return self
    }
    func setImageChain(_ image: UIImage?, for state: UIControl.State) -> Self {
        setImage(image, for: state)
        return self
    }

    func setBackgroundImageChain(_ image: UIImage?, for state: UIControl.State) -> Self {
        setBackgroundImage(image, for: state)
        return self
    }
    @available(iOS 13.0, *)
    func setPreferredSymbolConfigurationChain(_ configuration: UIImage.SymbolConfiguration?, forImageIn state: UIControl.State) -> Self {
        setPreferredSymbolConfiguration(configuration, forImageIn: state)
        return self
    }

    @available(iOS 6.0, *)
    func setAttributedTitleChain(_ title: NSAttributedString?, for state: UIControl.State) -> Self {
        setAttributedTitle(title, for: state)
        return self
    }

}

UILabel

public extension UILabel {

    // default is nil
    func text(_ text: String?) -> Self {
        self.text = text
        return self
    }

    // default is nil (system font 17 plain)
    func font(_ font: UIFont!) -> Self {
        self.font = font
        return self
    }

    // default is labelColor
    func textColor(_ textColor: UIColor!) -> Self {
        self.textColor = textColor
        return self
    }

    // default is nil (no shadow)
    func shadowColor(_ shadowColor: UIColor?) -> Self {
        self.shadowColor = shadowColor
        return self
    }

    // default is CGSizeMake(0, -1) -- a top shadow
    func shadowOffset(_ shadowOffset: CGSize) -> Self {
        self.shadowOffset = shadowOffset
        return self
    }

    // default is NSTextAlignmentNatural (before iOS 9, the default was NSTextAlignmentLeft)
    func textAlignment(_ textAlignment: NSTextAlignment) -> Self {
        self.textAlignment = textAlignment
        return self
    }

    // default is NSLineBreakByTruncatingTail. used for single and multiple lines of text
    func lineBreakMode(_ lineBreakMode: NSLineBreakMode) -> Self {
        self.lineBreakMode = lineBreakMode
        return self
    }

    // default is nil
    func highlightedTextColor(_ highlightedTextColor: UIColor?) -> Self {
        self.highlightedTextColor = highlightedTextColor
        return self
    }

    // default is NO
    func isHighlighted(_ isHighlighted: Bool) -> Self {
        self.isHighlighted = isHighlighted
        return self
    }

    // default is NO
    func isUserInteractionEnabled(_ isUserInteractionEnabled: Bool) -> Self {
        self.isUserInteractionEnabled = isUserInteractionEnabled
        return self
    }

    // default is YES. changes how the label is drawn
    func isEnabled(_ isEnabled: Bool) -> Self {
        self.isEnabled = isEnabled
        return self
    }

    func numberOfLines(_ numberOfLines: Int) -> Self {
        self.numberOfLines = numberOfLines
        return self
    }

    // default is NO
    func adjustsFontSizeToFitWidth(_ adjustsFontSizeToFitWidth: Bool) -> Self {
        self.adjustsFontSizeToFitWidth = adjustsFontSizeToFitWidth
        return self
    }

    // default is UIBaselineAdjustmentAlignBaselines
    func baselineAdjustment(_ baselineAdjustment: UIBaselineAdjustment) -> Self {
        self.baselineAdjustment = baselineAdjustment
        return self
    }

    // default is 0.0
    @available(iOS 6.0, *)
    func minimumScaleFactor(_ minimumScaleFactor: CGFloat) -> Self {
        self.minimumScaleFactor = minimumScaleFactor
        return self
    }

    // default is NO
    @available(iOS 9.0, *)
    func allowsDefaultTighteningForTruncation(_ allowsDefaultTighteningForTruncation: Bool) -> Self {
        self.allowsDefaultTighteningForTruncation = allowsDefaultTighteningForTruncation
        return self
    }

    func lineBreakStrategy(_ lineBreakStrategy: NSParagraphStyle.LineBreakStrategy) -> Self {
        self.lineBreakStrategy = lineBreakStrategy
        return self
    }

    @available(iOS 6.0, *)
    func preferredMaxLayoutWidth(_ preferredMaxLayoutWidth: CGFloat) -> Self {
        self.preferredMaxLayoutWidth = preferredMaxLayoutWidth
        return self
    }
}

UIImageView

public extension UIImageView {

    // default is nil
    func image(_ image: UIImage?) -> Self {
        self.image = image
        return self
    }

    // default is nil
    @available(iOS 3.0, *)
    func highlightedImage(_ highlightedImage: UIImage?) -> Self {
        self.highlightedImage = highlightedImage
        return self
    }

    @available(iOS 13.0, *)
    func preferredSymbolConfiguration(_ preferredSymbolConfiguration: UIImage.SymbolConfiguration?) -> Self {
        self.preferredSymbolConfiguration = preferredSymbolConfiguration
        return self
    }

    // default is NO
    func isUserInteractionEnabled(_ isUserInteractionEnabled: Bool) -> Self {
        self.isUserInteractionEnabled = isUserInteractionEnabled
        return self
    }

    // default is NO
    @available(iOS 3.0, *)
    func isHighlighted(_ isHighlighted: Bool) -> Self {
        self.isHighlighted = isHighlighted
        return self
    }

    // The array must contain UIImages. Setting hides the single image. default is nil
    func animationImages(_ animationImages: [UIImage]?) -> Self {
        self.animationImages = animationImages
        return self
    }

    // The array must contain UIImages. Setting hides the single image. default is nil
    @available(iOS 3.0, *)
    func highlightedAnimationImages(_ highlightedAnimationImages: [UIImage]?) -> Self {
        self.highlightedAnimationImages = highlightedAnimationImages
        return self
    }

    // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)
    func animationDuration(_ animationDuration: TimeInterval) -> Self {
        self.animationDuration = animationDuration
        return self
    }

    // 0 means infinite (default is 0)
    func animationRepeatCount(_ animationRepeatCount: Int) -> Self {
        self.animationRepeatCount = animationRepeatCount
        return self
    }

    @available(iOS 7.0, *)
    func tintColor(_ tintColor: UIColor!) -> Self {
        self.tintColor = tintColor
        return self
    }
}

UITextField

@available(iOS 2.0, *)
public extension UITextField {

    // default is nil
    func text(_ text: String?) -> Self {
        self.text = text
        return self
    }

    // default is nil
    @available(iOS 6.0, *)
    func attributedText(_ attributedText: NSAttributedString?) -> Self {
        self.attributedText = attributedText
        return self
    }

    // default is nil. use opaque black
    func textColor(_ textColor: UIColor?) -> Self {
        self.textColor = textColor
        return self
    }

    // default is nil. use system font 12 pt
    func font(_ font: UIFont?) -> Self {
        self.font = font
        return self
    }

    // default is NSLeftTextAlignment
    func textAlignment(_ textAlignment: NSTextAlignment) -> Self {
        self.textAlignment = textAlignment
        return self
    }

    // default is UITextBorderStyleNone. If set to UITextBorderStyleRoundedRect, custom background images are ignored.
    func borderStyle(_ borderStyle: UITextField.BorderStyle) -> Self {
        self.borderStyle = borderStyle
        return self
    }

    // applies attributes to the full range of text. Unset attributes act like default values.
    @available(iOS 7.0, *)
    func defaultTextAttributes(_ defaultTextAttributes: [NSAttributedString.Key : Any]) -> Self {
        self.defaultTextAttributes = defaultTextAttributes
        return self
    }

    // default is nil. string is drawn 70% gray
    func placeholder(_ placeholder: String?) -> Self {
        self.placeholder = placeholder
        return self
    }

    // default is nil
    @available(iOS 6.0, *)
    func attributedPlaceholder(_ attributedPlaceholder: NSAttributedString?) -> Self {
        self.attributedPlaceholder = attributedPlaceholder
        return self
    }

    // default is NO which moves cursor to location clicked. if YES, all text cleared
    func clearsOnBeginEditing(_ clearsOnBeginEditing: Bool) -> Self {
        self.clearsOnBeginEditing = clearsOnBeginEditing
        return self
    }

    // default is NO. if YES, text will shrink to minFontSize along baseline
    func adjustsFontSizeToFitWidth(_ adjustsFontSizeToFitWidth: Bool) -> Self {
        self.adjustsFontSizeToFitWidth = adjustsFontSizeToFitWidth
        return self
    }

    // default is 0.0. actual min may be pinned to something readable. used if adjustsFontSizeToFitWidth is YES
    func minimumFontSize(_ minimumFontSize: CGFloat) -> Self {
        self.minimumFontSize = minimumFontSize
        return self
    }

    // default is nil. weak reference
    func delegate(_ delegate: UITextFieldDelegate?) -> Self {
        self.delegate = delegate
        return self
    }

    // default is nil. draw in border rect. image should be stretchable
    func background(_ background: UIImage?) -> Self {
        self.background = background
        return self
    }

    // default is nil. ignored if background not set. image should be stretchable
    func disabledBackground(_ disabledBackground: UIImage?) -> Self {
        self.disabledBackground = disabledBackground
        return self
    }

    // default is NO. allows editing text attributes with style operations and pasting rich text
    @available(iOS 6.0, *)
    func allowsEditingTextAttributes(_ allowsEditingTextAttributes: Bool) -> Self {
        self.allowsEditingTextAttributes = allowsEditingTextAttributes
        return self
    }

    // automatically resets when the selection changes
    @available(iOS 6.0, *)
    func typingAttributes(_ typingAttributes: [NSAttributedString.Key : Any]) -> Self {
        self.typingAttributes = typingAttributes
        return self
    }

    // sets when the clear button shows up. default is UITextFieldViewModeNever
    func clearButtonMode(_ clearButtonMode: UITextField.ViewMode) -> Self {
        self.clearButtonMode = clearButtonMode
        return self
    }

    // e.g. magnifying glass
    func leftView(_ leftView: UIView?) -> Self {
        self.leftView = leftView
        return self
    }

    // sets when the left view shows up. default is UITextFieldViewModeNever
    func leftViewMode(_ leftViewMode: UITextField.ViewMode) -> Self {
        self.leftViewMode = leftViewMode
        return self
    }

    // e.g. bookmarks button
    func rightView(_ rightView: UIView?) -> Self {
        self.rightView = rightView
        return self
    }

    // sets when the right view shows up. default is UITextFieldViewModeNever
    func rightViewMode(_ rightViewMode: UITextField.ViewMode) -> Self {
        self.rightViewMode = rightViewMode
        return self
    }


    func inputView(_ inputView: UIView?) -> Self {
        self.inputView = inputView
        return self
    }


    func inputAccessoryView(_ inputAccessoryView: UIView?) -> Self {
        self.inputAccessoryView = inputAccessoryView
        return self
    }

    // defaults to NO. if YES, the selection UI is hidden, and inserting text will replace the contents of the field. changing the selection will automatically set this to NO.
    @available(iOS 6.0, *)
    func clearsOnInsertion(_ clearsOnInsertion: Bool) -> Self {
        self.clearsOnInsertion = clearsOnInsertion
        return self
    }

}

UITextView

public extension UITextView {


    func text(_ text: String!) -> Self {
        self.text = text
        return self
    }

    func font(_ font: UIFont?) -> Self {
        self.font = font
        return self
    }

    func textColor(_ textColor: UIColor?) -> Self {
        self.textColor = textColor
        return self
    }

    // default is NSLeftTextAlignment
    func textAlignment(_ textAlignment: NSTextAlignment) -> Self {
        self.textAlignment = textAlignment
        return self
    }

    func selectedRange(_ selectedRange: NSRange) -> Self {
        self.selectedRange = selectedRange
        return self
    }


    func isEditable(_ isEditable: Bool) -> Self {
        self.isEditable = isEditable
        return self
    }

    // toggle selectability, which controls the ability of the user to select content and interact with URLs & attachments. On tvOS this also makes the text view focusable.
    @available(iOS 7.0, *)
    func isSelectable(_ isSelectable: Bool) -> Self {
        self.isSelectable = isSelectable
        return self
    }

    @available(iOS 3.0, *)
    func dataDetectorTypes(_ dataDetectorTypes: UIDataDetectorTypes) -> Self {
        self.dataDetectorTypes = dataDetectorTypes
        return self
    }

    // defaults to NO
    @available(iOS 6.0, *)
    func allowsEditingTextAttributes(_ allowsEditingTextAttributes: Bool) -> Self {
        self.allowsEditingTextAttributes = allowsEditingTextAttributes
        return self
    }

    // automatically resets when the selection changes
    @available(iOS 6.0, *)
    func typingAttributes(_ typingAttributes: [NSAttributedString.Key : Any]) -> Self {
        self.typingAttributes = typingAttributes
        return self
    }

    func inputView(_ inputView: UIView?) -> Self {
        self.inputView = inputView
        return self
    }

    func inputAccessoryView(_ inputAccessoryView: UIView?) -> Self {
        self.inputAccessoryView = inputAccessoryView
        return self
    }

    // defaults to NO. if YES, the selection UI is hidden, and inserting text will replace the contents of the field. changing the selection will automatically set this to NO.
    @available(iOS 6.0, *)
    func clearsOnInsertion(_ clearsOnInsertion: Bool) -> Self {
        self.clearsOnInsertion = clearsOnInsertion
        return self
    }

    @available(iOS 7.0, *)
    func textContainerInset(_ textContainerInset: UIEdgeInsets) -> Self {
        self.textContainerInset = textContainerInset
        return self
    }

    @available(iOS 7.0, *)
    func linkTextAttributes(_ linkTextAttributes: [NSAttributedString.Key: Any]) -> Self {
        self.linkTextAttributes = linkTextAttributes
        return self
    }

    @available(iOS 13.0, *)
    func usesStandardTextScaling(_ usesStandardTextScaling: Bool) -> Self {
        self.usesStandardTextScaling = usesStandardTextScaling
        return self
    }

}

DateFormatter

@available(iOS 6.0, *)
public extension DateFormatter {

    // default is NSFormattingContextUnknown
    @available(iOS 8.0, *)
    func formattingContext(_ formattingContext: Formatter.Context) -> Self {
        self.formattingContext = formattingContext
        return self
    }


    func dateFormat(_ dateFormat: String!) -> Self {
        self.dateFormat = dateFormat
        return self
    }


    func dateStyle(_ dateStyle: DateFormatter.Style) -> Self {
        self.dateStyle = dateStyle
        return self
    }


    func timeStyle(_ timeStyle: DateFormatter.Style) -> Self {
        self.timeStyle = timeStyle
        return self
    }


    func locale(_ locale: Locale!) -> Self {
        self.locale = locale
        return self
    }


    func generatesCalendarDates(_ generatesCalendarDates: Bool) -> Self {
        self.generatesCalendarDates = generatesCalendarDates
        return self
    }


    func formatterBehavior(_ formatterBehavior: DateFormatter.Behavior) -> Self {
        self.formatterBehavior = formatterBehavior
        return self
    }


    func timeZone(_ timeZone: TimeZone!) -> Self {
        self.timeZone = timeZone
        return self
    }


    func calendar(_ calendar: Calendar!) -> Self {
        self.calendar = calendar
        return self
    }


    func isLenient(_ isLenient: Bool) -> Self {
        self.isLenient = isLenient
        return self
    }


    func twoDigitStartDate(_ twoDigitStartDate: Date?) -> Self {
        self.twoDigitStartDate = twoDigitStartDate
        return self
    }


    func defaultDate(_ defaultDate: Date?) -> Self {
        self.defaultDate = defaultDate
        return self
    }


    func eraSymbols(_ eraSymbols: [String]) -> Self {
        self.eraSymbols = eraSymbols
        return self
    }


    func monthSymbols(_ monthSymbols: [String]) -> Self {
        self.monthSymbols = monthSymbols
        return self
    }


    func shortMonthSymbols(_ shortMonthSymbols: [String]) -> Self {
        self.shortMonthSymbols = shortMonthSymbols
        return self
    }


    func weekdaySymbols(_ weekdaySymbols: [String]) -> Self {
        self.weekdaySymbols = weekdaySymbols
        return self
    }


    func shortWeekdaySymbols(_ shortWeekdaySymbols: [String]) -> Self {
        self.shortWeekdaySymbols = shortWeekdaySymbols
        return self
    }


    func amSymbol(_ amSymbol: String!) -> Self {
        self.amSymbol = amSymbol
        return self
    }


    func pmSymbol(_ pmSymbol: String!) -> Self {
        self.pmSymbol = pmSymbol
        return self
    }

    func longEraSymbols(_ longEraSymbols: [String]) -> Self {
        self.longEraSymbols = longEraSymbols
        return self
    }

    func veryShortMonthSymbols(_ veryShortMonthSymbols: [String]) -> Self {
        self.veryShortMonthSymbols = veryShortMonthSymbols
        return self
    }

    func standaloneMonthSymbols(_ standaloneMonthSymbols: [String]) -> Self {
        self.standaloneMonthSymbols = standaloneMonthSymbols
        return self
    }

    func shortStandaloneMonthSymbols(_ shortStandaloneMonthSymbols: [String]) -> Self {
        self.shortStandaloneMonthSymbols = shortStandaloneMonthSymbols
        return self
    }

    func veryShortStandaloneMonthSymbols(_ veryShortStandaloneMonthSymbols: [String]) -> Self {
        self.veryShortStandaloneMonthSymbols = veryShortStandaloneMonthSymbols
        return self
    }

    func veryShortWeekdaySymbols(_ veryShortWeekdaySymbols: [String]) -> Self {
        self.veryShortWeekdaySymbols = veryShortWeekdaySymbols
        return self
    }

    func standaloneWeekdaySymbols(_ standaloneWeekdaySymbols: [String]) -> Self {
        self.standaloneWeekdaySymbols = standaloneWeekdaySymbols
        return self
    }

    func shortStandaloneWeekdaySymbols(_ shortStandaloneWeekdaySymbols: [String]) -> Self {
        self.shortStandaloneWeekdaySymbols = shortStandaloneWeekdaySymbols
        return self
    }

    func veryShortStandaloneWeekdaySymbols(_ veryShortStandaloneWeekdaySymbols: [String]) -> Self {
        self.veryShortStandaloneWeekdaySymbols = veryShortStandaloneWeekdaySymbols
        return self
    }

    func quarterSymbols(_ quarterSymbols: [String]) -> Self {
        self.quarterSymbols = quarterSymbols
        return self
    }

    func shortQuarterSymbols(_ shortQuarterSymbols: [String]) -> Self {
        self.shortQuarterSymbols = shortQuarterSymbols
        return self
    }

    func standaloneQuarterSymbols(_ standaloneQuarterSymbols: [String]) -> Self {
        self.standaloneQuarterSymbols = standaloneQuarterSymbols
        return self
    }

    func shortStandaloneQuarterSymbols(_ shortStandaloneQuarterSymbols: [String]) -> Self {
        self.shortStandaloneQuarterSymbols = shortStandaloneQuarterSymbols
        return self
    }

    func gregorianStartDate(_ gregorianStartDate: Date?) -> Self {
        self.gregorianStartDate = gregorianStartDate
        return self
    }

    func doesRelativeDateFormatting(_ doesRelativeDateFormatting: Bool) -> Self {
        self.doesRelativeDateFormatting = doesRelativeDateFormatting
        return self
    }

}

NumberFormatter

@available(iOS 6.0, *)
public extension NumberFormatter {

    @available(iOS 8.0, *)
    func formattingContext(_ formattingContext: Formatter.Context) -> Self {
        self.formattingContext = formattingContext
        return self
    }

    func numberStyle(_ numberStyle: NumberFormatter.Style) -> Self {
        self.numberStyle = numberStyle
        return self
    }

    func locale(_ locale: Locale!) -> Self {
        self.locale = locale
        return self
    }

    func generatesDecimalNumbers(_ generatesDecimalNumbers: Bool) -> Self {
        self.generatesDecimalNumbers = generatesDecimalNumbers
        return self
    }

    func formatterBehavior(_ formatterBehavior: NumberFormatter.Behavior) -> Self {
        self.formatterBehavior = formatterBehavior
        return self
    }

    func negativeFormat(_ negativeFormat: String!) -> Self {
        self.negativeFormat = negativeFormat
        return self
    }

    func textAttributesForNegativeValues(_ textAttributesForNegativeValues: [String : Any]) -> Self {
        self.textAttributesForNegativeValues = textAttributesForNegativeValues
        return self
    }

    func positiveFormat(_ positiveFormat: String!) -> Self {
        self.positiveFormat = positiveFormat
        return self
    }

    func textAttributesForPositiveValues(_ textAttributesForPositiveValues: [String : Any]) -> Self {
        self.textAttributesForPositiveValues = textAttributesForPositiveValues
        return self
    }

    func allowsFloats(_ allowsFloats: Bool) -> Self {
        self.allowsFloats = allowsFloats
        return self
    }

    func decimalSeparator(_ decimalSeparator: String!) -> Self {
        self.decimalSeparator = decimalSeparator
        return self
    }

    func alwaysShowsDecimalSeparator(_ alwaysShowsDecimalSeparator: Bool) -> Self {
        self.alwaysShowsDecimalSeparator = alwaysShowsDecimalSeparator
        return self
    }

    func currencyDecimalSeparator(_ currencyDecimalSeparator: String!) -> Self {
        self.currencyDecimalSeparator = currencyDecimalSeparator
        return self
    }

    func usesGroupingSeparator(_ usesGroupingSeparator: Bool) -> Self {
        self.usesGroupingSeparator = usesGroupingSeparator
        return self
    }

    func groupingSeparator(_ groupingSeparator: String!) -> Self {
        self.groupingSeparator = groupingSeparator
        return self
    }

    func zeroSymbol(_ zeroSymbol: String?) -> Self {
        self.zeroSymbol = zeroSymbol
        return self
    }

    func textAttributesForZero(_ textAttributesForZero: [String : Any]) -> Self {
        self.textAttributesForZero = textAttributesForZero
        return self
    }

    func nilSymbol(_ nilSymbol: String) -> Self {
        self.nilSymbol = nilSymbol
        return self
    }

    func textAttributesForNil(_ textAttributesForNil: [String : Any]) -> Self {
        self.textAttributesForNil = textAttributesForNil
        return self
    }


    func notANumberSymbol(_ notANumberSymbol: String!) -> Self {
        self.notANumberSymbol = notANumberSymbol
        return self
    }

    func textAttributesForNotANumber(_ textAttributesForNotANumber: [String : Any]) -> Self {
        self.textAttributesForNotANumber = textAttributesForNotANumber
        return self
    }

    func positiveInfinitySymbol(_ positiveInfinitySymbol: String) -> Self {
        self.positiveInfinitySymbol = positiveInfinitySymbol
        return self
    }


    func textAttributesForPositiveInfinity(_ textAttributesForPositiveInfinity: [String : Any]) -> Self {
        self.textAttributesForPositiveInfinity = textAttributesForPositiveInfinity
        return self
    }

    func negativeInfinitySymbol(_ negativeInfinitySymbol: String) -> Self {
        self.negativeInfinitySymbol = negativeInfinitySymbol
        return self
    }

    func textAttributesForNegativeInfinity(_ textAttributesForNegativeInfinity: [String : Any]) -> Self {
        self.textAttributesForNegativeInfinity = textAttributesForNegativeInfinity
        return self
    }

    func positivePrefix(_ positivePrefix: String!) -> Self {
        self.positivePrefix = positivePrefix
        return self
    }

    func positiveSuffix(_ positiveSuffix: String!) -> Self {
        self.positiveSuffix = positiveSuffix
        return self
    }

    func negativePrefix(_ negativePrefix: String!) -> Self {
        self.negativePrefix = negativePrefix
        return self
    }

    func negativeSuffix(_ negativeSuffix: String!) -> Self {
        self.negativeSuffix = negativeSuffix
        return self
    }

    func currencyCode(_ currencyCode: String!) -> Self {
        self.currencyCode = currencyCode
        return self
    }

    func currencySymbol(_ currencySymbol: String!) -> Self {
        self.currencySymbol = currencySymbol
        return self
    }


    func internationalCurrencySymbol(_ internationalCurrencySymbol: String!) -> Self {
        self.internationalCurrencySymbol = internationalCurrencySymbol
        return self
    }


    func percentSymbol(_ percentSymbol: String!) -> Self {
        self.percentSymbol = percentSymbol
        return self
    }


    func perMillSymbol(_ perMillSymbol: String!) -> Self {
        self.perMillSymbol = perMillSymbol
        return self
    }


    func minusSign(_ minusSign: String!) -> Self {
        self.minusSign = minusSign
        return self
    }


    func plusSign(_ plusSign: String!) -> Self {
        self.plusSign = plusSign
        return self
    }


    func exponentSymbol(_ exponentSymbol: String!) -> Self {
        self.exponentSymbol = exponentSymbol
        return self
    }


    func groupingSize(_ groupingSize: Int) -> Self {
        self.groupingSize = groupingSize
        return self
    }


    func secondaryGroupingSize(_ secondaryGroupingSize: Int) -> Self {
        self.secondaryGroupingSize = secondaryGroupingSize
        return self
    }


    func multiplier(_ multiplier: NSNumber?) -> Self {
        self.multiplier = multiplier
        return self
    }


    func formatWidth(_ formatWidth: Int) -> Self {
        self.formatWidth = formatWidth
        return self
    }


    func paddingCharacter(_ paddingCharacter: String!) -> Self {
        self.paddingCharacter = paddingCharacter
        return self
    }


    func paddingPosition(_ paddingPosition: NumberFormatter.PadPosition) -> Self {
        self.paddingPosition = paddingPosition
        return self
    }


    func roundingMode(_ roundingMode: NumberFormatter.RoundingMode) -> Self {
        self.roundingMode = roundingMode
        return self
    }


    func roundingIncrement(_ roundingIncrement: NSNumber!) -> Self {
        self.roundingIncrement = roundingIncrement
        return self
    }


    func minimumIntegerDigits(_ minimumIntegerDigits: Int) -> Self {
        self.minimumIntegerDigits = minimumIntegerDigits
        return self
    }


    func maximumIntegerDigits(_ maximumIntegerDigits: Int) -> Self {
        self.maximumIntegerDigits = maximumIntegerDigits
        return self
    }


    func minimumFractionDigits(_ minimumFractionDigits: Int) -> Self {
        self.minimumFractionDigits = minimumFractionDigits
        return self
    }


    func maximumFractionDigits(_ maximumFractionDigits: Int) -> Self {
        self.maximumFractionDigits = maximumFractionDigits
        return self
    }


    func minimum(_ minimum: NSNumber?) -> Self {
        self.minimum = minimum
        return self
    }


    func maximum(_ maximum: NSNumber?) -> Self {
        self.maximum = maximum
        return self
    }

    func currencyGroupingSeparator(_ currencyGroupingSeparator: String!) -> Self {
        self.currencyGroupingSeparator = currencyGroupingSeparator
        return self
    }

    func isLenient(_ isLenient: Bool) -> Self {
        self.isLenient = isLenient
        return self
    }

    func usesSignificantDigits(_ usesSignificantDigits: Bool) -> Self {
        self.usesSignificantDigits = usesSignificantDigits
        return self
    }

    func minimumSignificantDigits(_ minimumSignificantDigits: Int) -> Self {
        self.minimumSignificantDigits = minimumSignificantDigits
        return self
    }

    func maximumSignificantDigits(_ maximumSignificantDigits: Int) -> Self {
        self.maximumSignificantDigits = maximumSignificantDigits
        return self
    }

    func isPartialStringValidationEnabled(_ isPartialStringValidationEnabled: Bool) -> Self {
        self.isPartialStringValidationEnabled = isPartialStringValidationEnabled
        return self
    }

}
上一篇 下一篇

猜你喜欢

热点阅读