清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
//每调用一次月份向下跳一月,跨年则为下一年1月 func getNextYearAndMonth () -> (year:Int,month:Int){ var next_year:Int = currentYear var next_month:Int = currentMonth + 1 if next_month > 12 { next_month=1 next_year++ } //Swift可以同时返回多个值,返回值类型为元组 return (next_year,next_month) } //每调用一次月份向上跳一月,跨年则为上一年12月 func getPrevYearAndMonth () -> (year:Int,month:Int){ var prev_year:Int = currentYear var prev_month:Int = currentMonth - 1 if prev_month == 0 { prev_month = 12 prev_year-- } return (prev_year,prev_month) }