Skip to content

Commit

Permalink
fixed bug with rating controller and textfield being added at the sam…
Browse files Browse the repository at this point in the history
…e time, added new feature for scaling image
  • Loading branch information
nimati committed Nov 13, 2016
1 parent a0c91ee commit 82422ec
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 deletions.
1 change: 1 addition & 0 deletions Example/Pods/FCAlertView/FCAlertView/Classes/FCAlertView.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions Example/Pods/FCAlertView/FCAlertView/Classes/FCAlertView.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FCAlertView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'FCAlertView'
s.version = '1.2.5'
s.version = '1.2.6'
s.summary = 'FCAlertView is a Flat Customizable AlertView'

# This description is used to generate tags and improve search results.
Expand Down
3 changes: 2 additions & 1 deletion FCAlertView/Classes/FCAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
UIButton *item5;

NSInteger currentRating;

}

// Delegate
Expand Down Expand Up @@ -102,6 +102,7 @@
@property BOOL detachButtons;
@property BOOL fullCircleCustomImage;
@property BOOL hideSeparatorLineView;
@property CGFloat customImageScale;

// Default Types of Alerts

Expand Down
31 changes: 17 additions & 14 deletions FCAlertView/Classes/FCAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ - (id)init
_detachButtons = NO;
_fullCircleCustomImage = NO;
_hideSeparatorLineView = NO;
_customImageScale = 1;

defaultSpacing = [self configureAVWidth];
defaultHeight = [self configureAVHeight];
Expand Down Expand Up @@ -151,7 +152,7 @@ - (void) checkCustomizationValid {

if (_subTitle == nil || [_subTitle isEqualToString:@""])
if (_title == nil || [_title isEqualToString:@""])
_subTitle = @"You need to have a title or subtitle to use FCAlertView 😀";
NSLog(@"FCAlertView Warning: Your Alert should have a title and/or subtitle.");

if (doneTitle == nil || [doneTitle isEqualToString:@""]) {
doneTitle = @"OK";
Expand Down Expand Up @@ -277,7 +278,7 @@ - (void)drawRect:(CGRect)rect {
result.width - defaultSpacing,
defaultHeight - 30);

if (self.title == nil) // Frames for when AlertView doesn't contain a title
if (_title == nil || _title.length == 0) // Frames for when AlertView doesn't contain a title
alertViewFrame = CGRectMake(self.frame.size.width/2 - ((result.width - defaultSpacing)/2),
self.frame.size.height/2 - ((alertViewFrame.size.height - 50)/2),
result.width - defaultSpacing,
Expand Down Expand Up @@ -334,7 +335,7 @@ - (void)drawRect:(CGRect)rect {

NSInteger descriptionLevel = 45.0f;

if (_title == nil) {
if (_title == nil || _title.length == 0) {

descriptionLevel = 15.0f;
alertViewFrame = CGRectMake(alertViewFrame.origin.x,
Expand Down Expand Up @@ -844,18 +845,20 @@ - (void)drawRect:(CGRect)rect {
alertViewVector.image = [vectorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}

if (_fullCircleCustomImage) {
alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - 30.0f,
-30.0f,
60.0f,
60.0f);
} else {
alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - 15.0f,
-15.0f,
30.0f,
30.0f);
if (_fullCircleCustomImage)
_customImageScale = 2;

if (_customImageScale <= 0) {
_customImageScale = 1;
}

CGFloat vectorSize = 30.0f * MIN(2, _customImageScale);

alertViewVector.frame = CGRectMake(alertViewContents.frame.size.width/2 - (vectorSize/2),
-(vectorSize/2) - 0.5,
vectorSize,
vectorSize);

alertViewVector.contentMode = UIViewContentModeScaleAspectFit;
alertViewVector.userInteractionEnabled = 0;
alertViewVector.tintColor = _colorScheme;
Expand Down Expand Up @@ -915,7 +918,7 @@ - (void)drawRect:(CGRect)rect {
// ADDING RATING SYSTEM

ratingController = [[UIView alloc] initWithFrame:CGRectMake(20,
descriptionLevel + descriptionLabelFrames.size.height + 32.5 + 15,
descriptionLevel + descriptionLabelFrames.size.height + 32.5 + 15+ (MIN(1, alertTextFields.count)*(_textField.frame.size.height + 7.5)),
alertViewFrame.size.width - 40,
40)];

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@ If you prefer the custom image for you alert to be full width of the image circl
alert.fullCircleCustomImage = YES;
```

### Custom Image Scaling

If you prefer the custom image for you alert to be scaled up or down to a certain size, use:

```Objective-C
alert.customImageScale = 1.5; // Change 1.5 to how big or small you want to scale your custom alert image ranged from 0 to 2
```

### Hiding Separator Lines

To hide the separator lines that appear between the done and custom buttons of the alert, add:
Expand Down

0 comments on commit 82422ec

Please sign in to comment.