阅读背景:

iOS中根据月和日获取星座名

来源:互联网 


/**
 *  依据月和日的下标获得星座名
 *
 *  @param monthIndex 月的下标
 *  @param dayIndex   日的下标
 *
 *  @return 星座名
 */
- (NSString *)getConstellationNameByMonthIndex:(NSInteger)monthIndex dayIndex:(NSInteger)dayIndex {
    NSArray *constellations = @[@"水瓶座", @"双鱼座", @"白羊座", @"金牛座", @"双子座", @"巨蟹座", @"狮子座", @"处女座", @"天秤座", @"天蝎座", @"射手座", @"摩羯座"];
    NSInteger index;
    NSArray *conIndexs = @[@(20),@(19),@(21),@(20),@(21),@(22),@(23),@(23),@(23),@(24),@(23),@(22)];
    if ([[conIndexs objectAtIndex:monthIndex] integerValue] <= dayIndex + 1) {
        index = monthIndex;
    } else index = (monthIndex - 1 + 12) % 12;
    return [constellations objectAtIndex:index];
}/**
 *  依据月和日的下标获得星座名
 *




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: