A very flexible message bar for UIKit and SwiftUI.
MIT License
Bot releases are visible (Hide)
Published by wtmoose about 6 years ago
Published by wtmoose about 6 years ago
Published by wtmoose about 6 years ago
SwiftMessagesSegue
custom segue subclass. Try it out in the "View Controllers" section of the Demo app. In addition to the class documentation, more can be found in the View Controllers readme.CornerRoundingView
, which provides configurable corner rounding using squircles (the smoother method of rounding corners that you see on app icons). Nib files that feature rounded corners have their backgroundView
assigned to a CornerRoundingView
. CornerRoundingView
provides a roundsLeadingCorners
option to dynamically round only the leading corners of the view when presented from top or bottom (a feature used for the tab-style layouts).MarginAdjustable
to improve configurability of layout margins.backgroundView
is inset from the message view's edges.showDuration
and hideDuration
properties to the Animator
protocol (with default implementation that returns nil
). These values enable animations to work for view controller presentation.TopBottomAnimation.closePercentThreshold
Published by wtmoose over 6 years ago
Published by wtmoose over 6 years ago
Published by wtmoose over 6 years ago
windowViewController
property to SwiftMessages.Config
for supplying a custom subclass of WindowViewController
.TopBottomAnimation
now display properly under top and bottom bars.CenterAnimation
displayed on top or bottom instead of center (renamed to PhysicsAnimation
).Published by wtmoose about 7 years ago
Swift 4.0 syntax
Added support for iOS 11 and iPhone X. From the readme:
SwiftMessages 4 supports iOS 11 out-of-the-box with built-in support for safe areas. To ensur that message view layouts look just right when overlapping safe areas, views that adopt the MarginAdjustable
protocol (like MessageView
) will have their layout margins automatically adjusted by SwiftMessages. However, there is no one-size-fits-all adjustment, so the following properties were added to MarginAdjustable
to allow for additional adjustments to be made to the layout margins:
public protocol MarginAdjustable {
...
/// Safe area top adjustment in iOS 11+
var safeAreaTopOffset: CGFloat { get set }
/// Safe area bottom adjustment in iOS 11+
var safeAreaBottomOffset: CGFloat { get set }
}
If you're using using custom nib files or view classes and your layouts don't look quite right, try adjusting the values of these properties. BaseView
(the super class of MessageView
) declares these properties to be @IBDesignable
and you can find sample values in the nib files included with SwiftMessages.
Layout
enum capitalization to current Swift conventions.Published by wtmoose about 7 years ago
Added SwiftMessages.hideCounted(id:)
method of hiding. The counted method hides when the number of calls to show()
and hideCounted(id:)
for a
given message ID are equal. This can be useful for messages that may be
shown from multiple code paths to ensure that all paths are ready to hide.
Also added SwiftMessages.count(id:)
to get the current count and SwiftMessages.set(id:count:)
to set the current count.
Added ways to retrieve message views currently being shown, hidden, or queued to be shown.
// Get a message view with the given ID if it is currently
// being shown or hidden.
if let view = SwiftMessages.current(id: "some id") { ... }
// Get a message view with the given ID if is it currently
// queued to be shown.
if let view = SwiftMessages.queued(id: "some id") { ... }
// Get a message view with the given ID if it is currently being
// shown, hidden or in the queue to be shown.
if let view = SwiftMessages.currentOrQueued(id: "some id") { ... }
Identifiable
protocol by using the memory address as the ID.Published by wtmoose over 7 years ago
.center
presentation style with a physics-based dismissal gesture..custom(animator:)
presentation style, where you provide an instance of the Animator
protocol. The TopBottomAnimation
and CenterAnimation
animations both implement Animator
and may be subclassed (configuration options will be added in a future release). You may use the PhysicsPanHandler
class to incorporate a physics-based dismissal gesture into any custom animator..centered
message view layout with elements centered and arranged vertically.configureBackgroundView(width:)
and configureBackgroundView(sideMargin:)
convenience methods to MessageView
.Published by wtmoose over 7 years ago
Published by wtmoose over 7 years ago
MessageView
is smarter about including additional accessibility views for cases where you've added accessible elements to the view. Previously only the button
was included. Now all views where isAccessibilityElement == true
are included.
Note that all nib files now have isAccessibilityElement == false
for titleLabel
, bodyLabel
and iconLabel
(titleLabel
and bodyLabel
are read out as part of the overall message view's text). If any of these need to be directly accessible, then copy the nib file into your project and select "Enabled" in the Accessibility section of the Identity Inspector.
Published by wtmoose over 7 years ago
Fix regression where the UI was being blocked when using DimMode.none
.
Published by wtmoose over 7 years ago
From the README:
SwiftMessages provides excellent VoiceOver support out-of-the-box.
The title and body of the message are combined into a single announcement when the message is shown. The MessageView.accessibilityPrefix
property can be set to prepend additional clarifying text to the announcement.
Sometimes, a message may contain important visual cues that aren't captured in the title or body. For example, a message may rely on a yellow background to convey a warning rather than having the word "warning" in the title or body. In this case, it might be helpful to set MessageView.accessibilityPrefix = "warning"
.
If the message is shown with a dim view using config.dimMode
, elements below the dim view are not focusable until the message is hidden. If config.dimMode.interactive == true
, the dim view itself will be focusable and read out "dismiss" followed by "button". The former text can be customized by setting the config.dimModeAccessibilityLabel
property.
See the AccessibleMessage
protocol for implementing proper accessibility support in custom views.
Published by wtmoose over 7 years ago
Published by wtmoose over 7 years ago
Added the ability to display messages for an indefinite duration while enforcing a minimum duration using Duration.indefinite(delay:minimum)
.
This option is useful for displaying a message when a process is taking too long but you don't want to display the message if the process completes in a reasonable amount of time.
For example, if a URL load is expected to complete in 2 seconds, you may use the value unknown(delay: 2, minimum 1)
to ensure that the message will not be displayed most of the time, but will be displayed for at least 1 second if the operation takes longer than 2 seconds. By specifying a minimum duration, you can avoid hiding the message too fast if the operation finishes right after the delay interval.