diff --git a/README.md b/README.md index 9af869e..d12d859 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ The Android code was entirely created by me. For iOS most credits go to this excellent [Toast for iOS project by Charles Scalesse] (https://github.com/scalessec/Toast). ## 6. CHANGELOG +- 2.4.2: You can now also set the Toast `opacity` for iOS. - 2.4.1: As an addition to 2.4.0, [Sino](https://github.com/SinoBoeckmann) added the option to change the text color! - 2.4.0: You can now style the Toast with a number of properties. See - 2.3.2: The click event introduced with 2.3.0 did not work with Android 5+. diff --git a/package.json b/package.json index 6650f27..1bcaea1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-x-toast", - "version": "2.4.1", + "version": "2.4.2", "description": "This plugin allows you to show a Toast. A Toast is a little non intrusive buttonless popup which automatically disappears.", "cordova": { "id": "cordova-plugin-x-toast", diff --git a/plugin.xml b/plugin.xml index 294e8b4..d79a2d3 100755 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="2.4.2"> Toast diff --git a/src/ios/Toast+UIView.m b/src/ios/Toast+UIView.m index e832f3a..8b33055 100644 --- a/src/ios/Toast+UIView.m +++ b/src/ios/Toast+UIView.m @@ -140,11 +140,14 @@ static id styling; UIView *v = [vc view]; [v addSubview:toast]; + NSNumber * opacity = styling[@"opacity"]; + CGFloat theOpacity = opacity == nil ? CSToastOpacity : [opacity floatValue]; + [UIView animateWithDuration:CSToastFadeDuration delay:0.0 options:(UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction) animations:^{ - toast.alpha = CSToastOpacity; + toast.alpha = theOpacity; } completion:^(BOOL finished) { NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:duration target:self selector:@selector(toastTimerDidFinish:) userInfo:toast repeats:NO]; // associate the timer with the toast view @@ -319,16 +322,13 @@ static id styling; NSString * backgroundColor = styling[@"backgroundColor"]; UIColor *theColor = backgroundColor == nil ? [UIColor blackColor] : [self colorFromHexString:backgroundColor]; - NSNumber * opacity = styling[@"opacity"]; - CGFloat theOpacity = opacity == nil ? CSToastOpacity : [opacity floatValue]; - NSNumber * horizontalPadding = styling[@"horizontalPadding"]; NSNumber * verticalPadding = styling[@"verticalPadding"]; CGFloat theHorizontalPadding = horizontalPadding == nil ? CSToastHorizontalPadding : [horizontalPadding floatValue]; CGFloat theVerticalPadding = verticalPadding == nil ? CSToastVerticalPadding : [verticalPadding floatValue]; - wrapperView.backgroundColor = [theColor colorWithAlphaComponent:theOpacity]; - + wrapperView.backgroundColor = theColor; + if(image != nil) { imageView = [[UIImageView alloc] initWithImage:image]; imageView.contentMode = UIViewContentModeScaleAspectFit; @@ -349,7 +349,7 @@ static id styling; if (title != nil) { NSString * titleLabelTextColor = styling[@"textColor"]; UIColor *theTitleLabelTextColor = titleLabelTextColor == nil ? [UIColor whiteColor] : [self colorFromHexString:titleLabelTextColor]; - + titleLabel = [[UILabel alloc] init]; titleLabel.numberOfLines = CSToastMaxTitleLines; titleLabel.font = [UIFont boldSystemFontOfSize:CSToastFontSize]; @@ -369,7 +369,7 @@ static id styling; if (message != nil) { NSString * messageLabelTextColor = styling[@"textColor"]; UIColor *theMessageLabelTextColor = messageLabelTextColor == nil ? [UIColor whiteColor] : [self colorFromHexString:messageLabelTextColor]; - + messageLabel = [[UILabel alloc] init]; messageLabel.numberOfLines = CSToastMaxMessageLines; messageLabel.font = [UIFont systemFontOfSize:CSToastFontSize];