From 6541b63515f7242953ced37593ca6c00a6f5a34d Mon Sep 17 00:00:00 2001 From: BugkingK Date: Thu, 27 Aug 2020 09:50:06 +0900 Subject: [PATCH] Modify the bug where "nextIndex" is -1 when "currentIndex" is 0. --- Trident/MenuView.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Trident/MenuView.swift b/Trident/MenuView.swift index ce665a5..564c602 100644 --- a/Trident/MenuView.swift +++ b/Trident/MenuView.swift @@ -242,8 +242,12 @@ public class TridentMenuView: UIView { , currentIndex >= 0 else { return } - nextIndex = currentIndex == titles.count - 1 ? currentIndex - 1 : currentIndex + 1 -// nextIndex = min(currentIndex + 1, titles.count - 1) + if currentIndex == titles.count - 1 { + let next = currentIndex - 1 + nextIndex = next > 0 ? next : 0 + } else { + nextIndex = currentIndex + 1 + } currentLabel = menuItemViews[currentIndex] } }