Change buttonStyle Modifier based on light or dark mode in SwiftUI

前端 未结 2 1017
不知归路
不知归路 2021-01-07 01:41

I want to set Custom buttonStyle modifier for button for light and dark mode. How to change buttonStyle Modifier based on light or dark mode? I want to set Cus

2条回答
  •  不知归路
    2021-01-07 02:11

    You could define a named color in Assets.xcassets with a variation for the dark mode:

    This works out of the box even in a ButtonStyle:

    Color("ButtonBorder")
    

提交回复
热议问题