ios - 请问这种带尖角的view有什么好的实现方法
伊谢尔伦
伊谢尔伦 2017-04-18 09:49:55
0
8
1292

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回覆(8)
伊谢尔伦

程式猿的解決方法是;創建一個正方形的 view ; 背景顏色 和 那個主框顏色相同。 然後; 將這個 正方形 view 旋轉 90 度。 新增到 主框中。指定位置 即可。也就是,這個樣式是兩個 view 拼出來的。

左手右手慢动作

做一個氣泡圖片,然後放個tableView在裡面,做好固定的約束和圖片的slicing設定後,可以試試看這樣行不行? ?

伊谢尔伦

可以畫一個出來,省了切圖資源,效率也更高,方便重複使用。

- (UIView *)arrowView{
    if (!_arrowView) {
        // draw
        CGSize size = CGSizeMake(kDefaultArrowWeight, kDefaultArrowHeight);
        UIBezierPath *path = [[UIBezierPath alloc] init];
        [path moveToPoint:CGPointMake(size.width / 2.0, 0)];
        [path addLineToPoint:CGPointMake(0, size.height)];
        [path addLineToPoint:CGPointMake(size.width, size.height)];
        path.lineWidth = 1.0;
        
        CAShapeLayer *arrowLayer = [CAShapeLayer layer];
        arrowLayer.path = path.CGPath;
        
        _arrowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
        _arrowView.layer.mask = arrowLayer;
        _arrowView.backgroundColor = self.contentViewBackgroundColor;
    }
    return _arrowView;
}
PHPzhong

UIView上面貼一個三角形的imageview,上面再貼tableview。這樣滾動也沒問題,如果要調整imageView的位置也沒問題。

小葫芦

HTML:

<p class="test_triangle_border">
    <a href="#">三角形</a>
    <p class="popup">
        <span><em></em></span>测试
    </p>
</p>

  

CSS:

.test_triangle_border{
    width:200px;
    margin:0 auto 20px;
    position:relative;
}
.test_triangle_border a{
    color:#333;
    font-weight:bold;
    text-decoration:none;
}
.test_triangle_border .popup{
    width:100px;
    background:#cf0;
    padding:10px 20px;
    color:#333;
    border-radius:4px;
    position:absolute;
    top:30px;
    left:30px;
    border:1px solid #333;
}
.test_triangle_border .popup span{
    display:block;
    width:0;
    height:0;
    border-width:0 10px 10px;
    border-style:solid;
    border-color:transparent transparent #333;
    position:absolute;
    top:-10px;
    left:50%;/* 三角形居中显示 */
    margin-left:-10px;/* 三角形居中显示 */
}
.test_triangle_border .popup em{
    display:block;
    width:0;
    height:0;
    border-width:0 10px 10px;
    border-style:solid;
    border-color:transparent transparent #cf0;
    position:absolute;
    top:1px;
    left:-10px;
}

這是我答過別的的答案, 自己根據需求改吧

刘奇

這是個控制,iPad專用的.叫UIPopoverController.

阿神

是iOS8的話 可以用UIPopoverPresentationController

Peter_Zhu

美工 要個 圖片解決

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!