Use stand accessoryView mechanics
This commit is contained in:
parent
5127352f7a
commit
375c8bee04
@ -4,6 +4,34 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc
|
||||
class OWSColorPickerAccessoryView: NeverClearView {
|
||||
override var intrinsicContentSize: CGSize {
|
||||
return CGSize(width: kSwatchSize, height: kSwatchSize)
|
||||
}
|
||||
|
||||
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
||||
return self.intrinsicContentSize
|
||||
}
|
||||
|
||||
let kSwatchSize: CGFloat = 24
|
||||
|
||||
@objc
|
||||
required init(color: UIColor) {
|
||||
super.init(frame: .zero)
|
||||
|
||||
let circleView = CircleView()
|
||||
circleView.backgroundColor = color
|
||||
addSubview(circleView)
|
||||
circleView.autoSetDimensions(to: CGSize(width: kSwatchSize, height: kSwatchSize))
|
||||
circleView.autoPinEdgesToSuperviewEdges()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
@objc (OWSCircleView)
|
||||
class CircleView: UIView {
|
||||
override var bounds: CGRect {
|
||||
|
||||
@ -699,15 +699,8 @@ const CGFloat kIconViewLength = 24;
|
||||
iconName:(NSString *)iconName
|
||||
disclosureIconColor:(UIColor *)disclosureIconColor
|
||||
{
|
||||
UIView *accessoryView = [NeverClearView new];
|
||||
OWSCircleView *swatchView = [OWSCircleView new];
|
||||
[accessoryView addSubview:swatchView];
|
||||
[swatchView autoPinEdgesToSuperviewEdges];
|
||||
|
||||
const CGFloat kSwatchWidth = 20;
|
||||
[swatchView autoSetDimensionsToSize:CGSizeMake(kSwatchWidth, kSwatchWidth)];
|
||||
swatchView.backgroundColor = disclosureIconColor;
|
||||
[swatchView setCompressionResistanceHigh];
|
||||
OWSColorPickerAccessoryView *accessoryView =
|
||||
[[OWSColorPickerAccessoryView alloc] initWithColor:disclosureIconColor];
|
||||
|
||||
UITableViewCell *cell = [self cellWithName:name iconName:iconName customAccessoryView:accessoryView];
|
||||
// cell.accessoryView = accessoryView;
|
||||
@ -742,14 +735,8 @@ const CGFloat kIconViewLength = 24;
|
||||
UIStackView *contentRow = [[UIStackView alloc] initWithArrangedSubviews:@[ iconView, rowLabel ]];
|
||||
if (customAccessoryView) {
|
||||
OWSAssertDebug(cell.accessoryView == nil);
|
||||
UIView *accessoryView = [UIView containerView];
|
||||
[accessoryView autoSetDimensionsToSize:CGSizeMake(kIconViewLength, kIconViewLength)];
|
||||
[accessoryView addSubview:customAccessoryView];
|
||||
|
||||
[customAccessoryView autoAlignAxis:ALAxisHorizontal toSameAxisOfView:accessoryView withOffset:0];
|
||||
[customAccessoryView autoAlignAxis:ALAxisVertical toSameAxisOfView:accessoryView withOffset:6];
|
||||
|
||||
[contentRow addArrangedSubview:accessoryView];
|
||||
[customAccessoryView sizeToFit];
|
||||
cell.accessoryView = customAccessoryView;
|
||||
}
|
||||
contentRow.spacing = self.iconSpacing;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user