let alert = UIAlertController(title: "", message: "提交成功!感谢您的反馈,我们将持续为您改进。", preferredStyle: .alert)
let sureAction = UIAlertAction(title: "确定", style: .default) { [weak self] _ in
self?.navigationController?.popViewController(animated: true)
}
let originStr = "提交成功!感谢您的反馈,我们将持续为您改进。"
let attrStr = NSMutableAttributedString(string: originStr)
let style = NSMutableParagraphStyle()
style.alignment = .left
attrStr.addAttributes([NSAttributedString.Key.paragraphStyle: style], range: NSMakeRange(0, originStr.count))
attrStr.addAttributes([NSAttributedStringKey.font: UIFont(name: "PingFangSC-Regular", size: 15) ?? UIFont.systemFont(ofSize: 15)], range: NSMakeRange(0, originStr.count))
alert.setValue(attrStr, forKey: "attributedMessage")
alert.addAction(sureAction)
present(alert, animated: true, completion: nil)
附上UIAlertController的IvarList和PropertyList,其他自定义需求可自行key Value
********** UIAlertController IvarList ****************
_message ----- @"NSString"
_attributedTitle ----- @"NSAttributedString"
_attributedMessage ----- @"NSAttributedString"
_attributedDetailMessage ----- @"NSAttributedString"
_linkedAlertControllers ----- @"NSSet"
_cancelAction ----- @"UIAlertAction"
_actionToKeyCommandsDictionary ----- @"NSMutableDictionary"
_keyCommandToActionMapTable ----- @"NSMapTable"
_resolvedStyle ----- q
_preferredStyle ----- q
_contentViewController ----- @"UIViewController"
_textFieldViewController ----- @"_UIAlertControllerTextFieldViewController"
_backButtonDismissGestureRecognizer ----- @"UITapGestureRecognizer"
_ownedTransitioningDelegate ----- @
_addContentViewControllerToViewHierarchyNeeded ----- B
_isInSupportedInterfaceOrientations ----- B
_batchActionChangesInProgressCount ----- q
_presenter ----- @"_UIAlertControllerShimPresenter"
_actionsWithInvokedHandlers ----- @"NSPointerArray"
_hidden ----- B
_springLoaded ----- B
__shouldFlipFrameForShimDismissal ----- B
__shouldAllowNilParameters ----- B
_hasPreservedInputViews ----- B
_actions ----- @"NSMutableArray"
_headerContentViewController ----- @"UIViewController"
_styleProvider ----- @"NSObject<UIAlertControllerVisualStyleProviding>"
_preferredAction ----- @"UIAlertAction"
_temporaryAnimationCoordinator ----- @"_UIAnimationCoordinator"
_previewInteractionController ----- @"UIPreviewInteractionController"
__visualStyle ----- @"UIAlertControllerVisualStyle"
_accessibilityViewControllerForSizing ----- @"UIViewController"
_indexesOfActionSectionSeparators ----- @"NSIndexSet"
__actionDelimiterIndices ----- @"NSMutableArray"
__compatibilityPopoverController ----- @"UIPopoverController"
__systemProvidedPresentationView ----- @"UIView"
__systemProvidedPresentationDelegate ----- @"<UIAlertControllerSystemProvidedPresentationDelegate>"
_systemProvidedGestureRecognizer ----- @"UIGestureRecognizer"
_coordinatedActionPerformingDelegate ----- @"<UIAlertControllerCoordinatedActionPerforming>"
__presentationSourceRepresentationView ----- @"UIView"
_titleMaximumLineCount ----- q
_titleLineBreakMode ----- q
********** UIAlertController PropertyList ****************
hash ------ TQ,R
superclass ------ T#,R
description ------ T@"NSString",R,C
debugDescription ------ T@"NSString",R,C
_shouldFlipFrameForShimDismissal ------ TB,V__shouldFlipFrameForShimDismissal
temporaryAnimationCoordinator ------ T@"_UIAnimationCoordinator",&,N,V_temporaryAnimationCoordinator
previewInteractionController ------ T@"UIPreviewInteractionController",&,N,G_previewInteractionController,S_setPreviewInteractionController:,V_previewInteractionController
_visualStyle ------ T@"UIAlertControllerVisualStyle",&,N,S_setVisualStyle:,V__visualStyle
accessibilityViewControllerForSizing ------ T@"UIViewController",&,N,G_getAccessibilityViewControllerForSizing,S_setAccessibilityViewControllerForSizing:,V_accessibilityViewControllerForSizing
_actions ------ T@"NSMutableArray",R,V_actions
indexesOfActionSectionSeparators ------ T@"NSIndexSet",C,N,G_indexesOfActionSectionSeparators,S_setIndexesOfActionSectionSeparators:,V_indexesOfActionSectionSeparators
_cancelAction ------ T@"UIAlertAction",R,V_cancelAction
_focusedAction ------ T@"UIAlertAction",R
_actionDelimiterIndices ------ T@"NSMutableArray",R,V__actionDelimiterIndices
_foregroundView ------ T@"UIView",R
_dimmingView ------ T@"UIView",R
_resolvedStyle ------ Tq,R,V_resolvedStyle
_shouldProvideDimmingView ------ TB,R
_shouldAlignToKeyboard ------ TB,R
_hidden ------ TB,N,G_isHidden,S_setHidden:,V_hidden
effectAlpha ------ Td,N,G_effectAlpha,S_setEffectAlpha:
_shouldAllowNilParameters ------ TB,S_setShouldAllowNilParameters:,V__shouldAllowNilParameters
_compatibilityPopoverController ------ T@"UIPopoverController",N,S_setCompatibilityPopoverController:,V__compatibilityPopoverController
_textFieldViewController ------ T@"_UIAlertControllerTextFieldViewController",R
_textFieldsHidden ------ TB,S_setTextFieldsHidden:
hasPreservedInputViews ------ TB,N,G_hasPreservedInputViews,S_setHasPreservedInputViews:,V_hasPreservedInputViews
_systemProvidedPresentationView ------ T@"UIView",&,N,S_setSystemProvidedPresentationView:,V__systemProvidedPresentationView
_systemProvidedPresentationDelegate ------ T@"<UIAlertControllerSystemProvidedPresentationDelegate>",&,N,S_setSystemProvidedPresentationDelegate:,V__systemProvidedPresentationDelegate
systemProvidedGestureRecognizer ------ T@"UIGestureRecognizer",&,N,G_systemProvidedGestureRecognizer,S_setSystemProvidedGestureRecognizer:,V_systemProvidedGestureRecognizer
_attributedDetailMessage ------ T@"NSAttributedString",C,N,G_attributedDetailMessage,S_setAttributedDetailMessage:
styleProvider ------ T@"NSObject<UIAlertControllerVisualStyleProviding>",W,N,G_styleProvider,S_setStyleProvider:,V_styleProvider
coordinatedActionPerformingDelegate ------ T@"<UIAlertControllerCoordinatedActionPerforming>",W,N,V_coordinatedActionPerformingDelegate
_presentationSourceRepresentationView ------ T@"UIView",&,N,S_setPresentationSourceRepresentationView:,V__presentationSourceRepresentationView
_shouldReverseActions ------ TB,R
_headerContentViewController ------ T@"UIViewController",&,N,S_setHeaderContentViewController:,V_headerContentViewController
contentViewController ------ T@"UIViewController",&,N
preferredStyle ------ Tq,N
titleMaximumLineCount ------ Tq,N,G_titleMaximumLineCount,S_setTitleMaximumLineCount:,V_titleMaximumLineCount
titleLineBreakMode ------ Tq,N,G_titleLineBreakMode,S_setTitleLineBreakMode:,V_titleLineBreakMode
attributedTitle ------ T@"NSAttributedString",C,N,G_attributedTitle,S_setAttributedTitle:
attributedMessage ------ T@"NSAttributedString",C,N,G_attributedMessage,S_setAttributedMessage:
actions ------ T@"NSArray",&,N,S_setActions:
preferredAction ------ T@"UIAlertAction",&,N,V_preferredAction
textFields ------ T@"NSArray",R,N
title ------ T@"NSString",C,D,N
message ------ T@"NSString",C,N
hash ------ TQ,R
superclass ------ T#,R
description ------ T@"NSString",R,C
debugDescription ------ T@"NSString",R,C
网友评论