diff --git a/Vector/Views/RoomTitle/RoomAvatarTitleView.h b/Vector/Views/RoomTitle/RoomAvatarTitleView.h index 9698a5c74..0b64ce86a 100644 --- a/Vector/Views/RoomTitle/RoomAvatarTitleView.h +++ b/Vector/Views/RoomTitle/RoomAvatarTitleView.h @@ -19,5 +19,6 @@ @interface RoomAvatarTitleView : MXKRoomTitleView @property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomAvatarCenterXConstraint; @end \ No newline at end of file diff --git a/Vector/Views/RoomTitle/RoomAvatarTitleView.m b/Vector/Views/RoomTitle/RoomAvatarTitleView.m index f586ca8fe..32bfbbd61 100644 --- a/Vector/Views/RoomTitle/RoomAvatarTitleView.m +++ b/Vector/Views/RoomTitle/RoomAvatarTitleView.m @@ -33,6 +33,22 @@ [super awakeFromNib]; } +- (void)layoutSubviews +{ + [super layoutSubviews]; + + if (self.superview) + { + // Center horizontally the avatar according to the actual screen center + CGRect frame = self.superview.frame; + CGSize screenSize = [[UIScreen mainScreen] bounds].size; + + CGFloat superviewCenterX = frame.origin.x + (frame.size.width / 2); + + self.roomAvatarCenterXConstraint.constant = (screenSize.width / 2) - superviewCenterX; + } +} + - (void)refreshDisplay { [super refreshDisplay]; diff --git a/Vector/Views/RoomTitle/RoomAvatarTitleView.xib b/Vector/Views/RoomTitle/RoomAvatarTitleView.xib index 8420c11bd..df72e35ea 100644 --- a/Vector/Views/RoomTitle/RoomAvatarTitleView.xib +++ b/Vector/Views/RoomTitle/RoomAvatarTitleView.xib @@ -1,8 +1,8 @@ - + - + @@ -13,7 +13,7 @@ - + @@ -23,12 +23,13 @@ - + + diff --git a/Vector/Views/RoomTitle/RoomTitleView.h b/Vector/Views/RoomTitle/RoomTitleView.h index e2931b384..eead0112b 100644 --- a/Vector/Views/RoomTitle/RoomTitleView.h +++ b/Vector/Views/RoomTitle/RoomTitleView.h @@ -34,6 +34,7 @@ @property (weak, nonatomic) IBOutlet UIView *titleMask; @property (weak, nonatomic) IBOutlet UIView *roomDetailsMask; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *displayNameCenterXConstraint; /** The tap gesture delegate. diff --git a/Vector/Views/RoomTitle/RoomTitleView.m b/Vector/Views/RoomTitle/RoomTitleView.m index ee25f804b..7436aad39 100644 --- a/Vector/Views/RoomTitle/RoomTitleView.m +++ b/Vector/Views/RoomTitle/RoomTitleView.m @@ -49,6 +49,23 @@ self.roomDetailsMask.userInteractionEnabled = YES; } +- (void)layoutSubviews +{ + [super layoutSubviews]; + + if (self.superview) + { + // Center horizontally the display name according to the actual screen center + CGRect frame = self.superview.frame; + CGSize screenSize = [[UIScreen mainScreen] bounds].size; + + CGFloat superviewCenterX = frame.origin.x + (frame.size.width / 2); + + // Center the display name + self.displayNameCenterXConstraint.constant = (screenSize.width / 2) - superviewCenterX; + } +} + - (void)refreshDisplay { [super refreshDisplay]; diff --git a/Vector/Views/RoomTitle/RoomTitleView.xib b/Vector/Views/RoomTitle/RoomTitleView.xib index ccb03b186..8022e781e 100644 --- a/Vector/Views/RoomTitle/RoomTitleView.xib +++ b/Vector/Views/RoomTitle/RoomTitleView.xib @@ -1,8 +1,8 @@ - + - + @@ -12,7 +12,7 @@ - + @@ -21,24 +21,24 @@ - + - + - + - + @@ -56,6 +56,7 @@ +