首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

HMSegmentedControl源代码解析(7)

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];
    }
返回列表