RoomTitleView: Fix iOS 8 issue

Center horizontally the display name and the avatar.
This commit is contained in:
giomfo
2016-02-12 10:40:23 +01:00
parent eaba671b8e
commit fa2e81b33e
6 changed files with 48 additions and 11 deletions
@@ -19,5 +19,6 @@
@interface RoomAvatarTitleView : MXKRoomTitleView
@property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomAvatarCenterXConstraint;
@end
@@ -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];
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9532"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
@@ -13,7 +13,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7U9-Y6-cEm" customClass="MXKImageView">
<rect key="frame" x="251" y="13" width="84" height="84"/>
<rect key="frame" x="258" y="13" width="84" height="84"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="7U9-Y6-cEm" secondAttribute="height" multiplier="1:1" id="9ct-O9-7am"/>
@@ -23,12 +23,13 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="7U9-Y6-cEm" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" constant="-7" id="C5g-ho-90L"/>
<constraint firstItem="7U9-Y6-cEm" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="C5g-ho-90L"/>
<constraint firstItem="7U9-Y6-cEm" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="13" id="Kwt-Sd-REk"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="roomAvatar" destination="7U9-Y6-cEm" id="VWF-cH-9Jv"/>
<outlet property="roomAvatarCenterXConstraint" destination="C5g-ho-90L" id="D2d-zo-km6"/>
</connections>
</view>
</objects>
+1
View File
@@ -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.
+17
View File
@@ -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];
+8 -7
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
@@ -12,7 +12,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Room Name" textAlignment="center" adjustsFontSizeToFit="NO" minimumFontSize="14" translatesAutoresizingMaskIntoConstraints="NO" id="6uH-I3-RQg">
<rect key="frame" x="242" y="9" width="103" height="22"/>
<rect key="frame" x="249" y="9" width="103" height="22"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<textInputTraits key="textInputTraits" returnKeyType="next"/>
@@ -21,24 +21,24 @@
</connections>
</textField>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="details_icon" translatesAutoresizingMaskIntoConstraints="NO" id="S3Y-wJ-HOe">
<rect key="frame" x="352" y="14" width="6" height="12"/>
<rect key="frame" x="359" y="14" width="6" height="12"/>
<constraints>
<constraint firstAttribute="width" constant="6" id="XTx-6p-2wB"/>
<constraint firstAttribute="height" constant="12" id="tXh-eB-ave"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sD9-l7-azQ">
<rect key="frame" x="0.0" y="0.0" width="345" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="352" height="44"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pFg-XE-6DB">
<rect key="frame" x="345" y="0.0" width="255" height="44"/>
<rect key="frame" x="352" y="0.0" width="248" height="44"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" constant="-7" id="3uN-6W-rVZ"/>
<constraint firstItem="6uH-I3-RQg" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="3uN-6W-rVZ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="S3Y-wJ-HOe" secondAttribute="trailing" id="3z3-Ye-wh3"/>
<constraint firstAttribute="bottom" secondItem="sD9-l7-azQ" secondAttribute="bottom" id="4rX-5O-LrO"/>
<constraint firstItem="sD9-l7-azQ" firstAttribute="leading" secondItem="BkF-x3-7fX" secondAttribute="leading" id="AJc-Aa-sht"/>
@@ -56,6 +56,7 @@
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="displayNameCenterXConstraint" destination="3uN-6W-rVZ" id="rck-yU-24s"/>
<outlet property="displayNameTextField" destination="6uH-I3-RQg" id="MfX-LQ-C2K"/>
<outlet property="displayNameTextFieldTopConstraint" destination="Piq-rp-Pae" id="jnL-Hz-TWn"/>
<outlet property="roomDetailsMask" destination="pFg-XE-6DB" id="7EF-K5-G0o"/>