Board logo

标题: HMSegmentedControl源代码解析(7) [打印本页]

作者: look_w    时间: 2019-2-19 17:37     标题: HMSegmentedControl源代码解析(7)

getter & setter

     
    - (void)setFrameCGRect)frame {
        [super setFrame:frame];
        
        [self updateSegmentsRects];
    }
     
    - (void)setSectionTitlesNSArray<NSString *> *)sectionTitles {
        _sectionTitles = sectionTitles;
        
        // Allows you to perform layout before the drawing cycle happens. -layoutIfNeeded forces layout early
        [self setNeedsLayout];
        [self setNeedsDisplay];
    }
     
    - (void)setSectionImagesNSArray<UIImage *> *)sectionImages {
        _sectionImages = sectionImages;
        
        [self setNeedsLayout];
        [self setNeedsDisplay];
    }
     
    - (void)setSelectionIndicatorLocationHMSegmentedControlSelectionIndicatorLocation)selectionIndicatorLocation {
        _selectionIndicatorLocation = selectionIndicatorLocation;
        
        if (selectionIndicatorLocation == HMSegmentedControlSelectionIndicatorLocationNone) {
            self.selectionIndicatorHeight = 0.0f;
        }
    }
     
    - (void)setSelectionIndicatorBoxOpacityCGFloat)selectionIndicatorBoxOpacity {
        _selectionIndicatorBoxOpacity = selectionIndicatorBoxOpacity;
        
        self.selectionIndicatorBoxLayer.opacity = _selectionIndicatorBoxOpacity;
    }
     
    - (void)setSegmentWidthStyleHMSegmentedControlSegmentWidthStyle)segmentWidthStyle {
        // Force HMSegmentedControlSegmentWidthStyleFixed when type is HMSegmentedControlTypeImages.
        if (self.type == HMSegmentedControlTypeImages) {
            _segmentWidthStyle = HMSegmentedControlSegmentWidthStyleFixed;
        } else {
            _segmentWidthStyle = segmentWidthStyle;
        }
    }
     
    - (void)setBorderTypeHMSegmentedControlBorderType)borderType {
        _borderType = borderType;
        [self setNeedsDisplay];
    }




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0