Skip to content
This repository was archived by the owner on Oct 30, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions JGActionSheet/JGActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,48 @@ - (instancetype)initWithTitle:(NSString *)title message:(NSString *)message cont
_contentView = contentView;

[self addSubview:self.contentView];


[self.contentView setTranslatesAutoresizingMaskIntoConstraints:FALSE];

// Width constraint
[self addConstraint:[NSLayoutConstraint constraintWithItem:_contentView
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:0]];

// Height constraint
[self addConstraint:[NSLayoutConstraint constraintWithItem:_contentView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant:0]];

// Center horizontally
[self addConstraint:[NSLayoutConstraint constraintWithItem:_contentView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0]];

// Center vertically
[self addConstraint:[NSLayoutConstraint constraintWithItem:_contentView
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterY
multiplier:1.0
constant:0.0]];

self.contentView.backgroundColor = [UIColor clearColor];
[self.contentView updateConstraints];
}

return self;
Expand Down