Displaying a message in iOS which has the same functionality as Toast in Android

前端 未结 19 1701
逝去的感伤
逝去的感伤 2020-12-12 12:35

I need to know if there is any method in iOS which behaves like Toast messages in Android. That is, I need to display a message which is dismissed automatically after few se

19条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 13:27

    1) Download toast-notifications-ios from this link

    2) go to Targets -> Build Phases and add -fno-objc-arc to the "compiler Sources" for relevant files

    3) make a function and #import "iToast.h"

    -(void)showToast :(NSString *)strMessage {
        iToast * objiTost = [iToast makeText:strMessage];
        [objiTost setFontSize:11];
        [objiTost setDuration:iToastDurationNormal];
        [objiTost setGravity:iToastGravityBottom];
        [objiTost show];
    }
    

    4) call where you need to display toast message

    [self showToast:@"This is example text."];
    

提交回复
热议问题